fix backend & frontend routing
This commit is contained in:
parent
d705107d35
commit
0f664d3890
|
@ -4,6 +4,11 @@ import S3 from './aws/s3'
|
||||||
import config from '../config.json'
|
import config from '../config.json'
|
||||||
import indexHtml from '../worker/index.html'
|
import indexHtml from '../worker/index.html'
|
||||||
|
|
||||||
|
FRONTEND_PATHS = [
|
||||||
|
'/', '/paste/text', '/paste/binary',
|
||||||
|
'/paste/text/', '/paste/binary/'
|
||||||
|
]
|
||||||
|
|
||||||
s3 = new S3 config
|
s3 = new S3 config
|
||||||
|
|
||||||
main = ->
|
main = ->
|
||||||
|
@ -20,7 +25,7 @@ handleRequest = (event) ->
|
||||||
# Handle request for static home page first
|
# Handle request for static home page first
|
||||||
if event.request.method == "GET"
|
if event.request.method == "GET"
|
||||||
parsedURL = new URL event.request.url
|
parsedURL = new URL event.request.url
|
||||||
if parsedURL.pathname == "/" || parsedURL.pathname == "/paste/"
|
if parsedURL.pathname in FRONTEND_PATHS
|
||||||
return new Response indexHtml,
|
return new Response indexHtml,
|
||||||
status: 200
|
status: 200
|
||||||
headers:
|
headers:
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Pastebin extends React.Component
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
if @state.switchToUpload
|
if @state.switchToUpload
|
||||||
return <Redirect to="/paste/binary/" />
|
return <Redirect to="/paste/binary" />
|
||||||
|
|
||||||
<div className="content-pastebin">
|
<div className="content-pastebin">
|
||||||
<ContentEditable
|
<ContentEditable
|
||||||
|
|
Loading…
Reference in a new issue