You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Such as in react, we often pack all the routes into one html bundle. I expected to handle all the request route and redirected them to the index.html, is there some way to do it elegant?
As for now, I used those code to do it, but it not perfect way, for example, request for JSON files maybe also redirected unexpectly:
app.serveFolder(path.join(buildDir,'static'),'static');app.serveHandler(asyncrequest=>{if(request.resourceType()!=='Document'){request.continue();return;}constheaders={'content-type': 'text/html'};constbody=awaitfsReadFile(path.join(buildDir,'index.html'));request.fulfill({ headers, body });});
The text was updated successfully, but these errors were encountered:
Such as in
react
, we often pack all the routes into one html bundle. I expected to handle all the request route and redirected them to theindex.html
, is there some way to do it elegant?As for now, I used those code to do it, but it not perfect way, for example, request for JSON files maybe also redirected unexpectly:
The text was updated successfully, but these errors were encountered: