fix backend & frontend routing

This commit is contained in:
Peter Cai 2020-02-18 17:43:23 +08:00
parent d705107d35
commit 0f664d3890
No known key found for this signature in database
GPG key ID: 71F5FB4E4F3FD54F
2 changed files with 7 additions and 2 deletions

View file

@ -4,6 +4,11 @@ import S3 from './aws/s3'
import config from '../config.json'
import indexHtml from '../worker/index.html'
FRONTEND_PATHS = [
'/', '/paste/text', '/paste/binary',
'/paste/text/', '/paste/binary/'
]
s3 = new S3 config
main = ->
@ -20,7 +25,7 @@ handleRequest = (event) ->
# Handle request for static home page first
if event.request.method == "GET"
parsedURL = new URL event.request.url
if parsedURL.pathname == "/" || parsedURL.pathname == "/paste/"
if parsedURL.pathname in FRONTEND_PATHS
return new Response indexHtml,
status: 200
headers:

View file

@ -55,7 +55,7 @@ class Pastebin extends React.Component
render: ->
if @state.switchToUpload
return <Redirect to="/paste/binary/" />
return <Redirect to="/paste/binary" />
<div className="content-pastebin">
<ContentEditable