Skip to content

Commit

Permalink
fix: Handle static assets on the rw-serve-fe (redwoodjs#10018)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Choudhury <dannychoudhury@gmail.com>
  • Loading branch information
Josh-Walker-GM and dac09 committed Feb 16, 2024
1 parent 0f158c2 commit 4891360
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/vite/src/runFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function runFeServer() {

if (rwConfig.experimental?.rsc?.enabled) {
console.log('='.repeat(80))
console.log('buildManifest', buildManifest.default)
console.log('buildManifest', buildManifest)
console.log('='.repeat(80))
}

Expand Down Expand Up @@ -175,6 +175,18 @@ export async function runFeServer() {
})
)

// Serve static assets that aren't covered by any of the above routes or middleware
// Note: That the order here is important and that we are explicitly preventing access
// to the server dist folder
// TODO: In the future, we should explicitly serve `web/dist/client` and `web/dist/rsc`
// and simply not serve the `web/dist/server` folder
app.use(`/${path.basename(rwPaths.web.distServer)}/*`, (_req, res, _next) => {
return res
.status(403)
.end('403 Forbidden: Access to server dist is forbidden')
})
app.use(express.static(rwPaths.web.dist, { index: false }))

app.listen(rwConfig.web.port)
console.log(
`Started production FE server on http://localhost:${rwConfig.web.port}`
Expand Down

0 comments on commit 4891360

Please sign in to comment.