-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Handle static assets on the rw-serve-fe
#10018
Conversation
@@ -175,6 +175,9 @@ export async function runFeServer() { | |||
}) | |||
) | |||
|
|||
// Serve static assets that aren't covered by any of the above routes or middleware | |||
app.use(express.static(rwPaths.web.dist, { index: false })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Josh, this looks fine! But could we also get it to ignore everything in the web.dist.server
directory?
I'm changing how this stuff will work for rsc builds anyway, but doesn't hurt to be thorough now.
For reference I'm going to go with this folder structure, like we discussed before:
web/dist
├── client
│ ├── README.md
│ ├── assets
│ ├── client-build-manifest.json
│ ├── favicon.png
│ ├── index.html
│ └── robots.txt
├── rsc
│ ├── README.md
│ ├── assets
│ ├── entries.js
│ ├── favicon.png
│ ├── robots.txt
│ └── server-build-manifest.json
└── server
├── Document.js
├── README.md
├── assets
├── entry.server.js
├── favicon.png
├── robots.txt
└── route-manifest.json
So there's no risk of accidentally leaking code we don't want to!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you've implemented this nesting I think we will have an easier time only exposing what we intend to. For now, I need to expose it all and then block the server dist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly.
Changed the milestone for consistency. I use SSR so that we can find all these PRs later in one go. Thanks Josh ☮️ |
* 'main' of github.com:redwoodjs/redwood: (22 commits) fix: Handle static assets on the `rw-serve-fe` (redwoodjs#10018) fix(server): fix env var loading in `createServer` (redwoodjs#10021) fix(deps): remove react types packages from `@redwoodjs/testing` dependencies (redwoodjs#10020) chore(release): add back `update-package-versions` task (redwoodjs#10017) chore(renovate): Disable for experimental apollo package (redwoodjs#10016) RSC: server cells lowercase data function (redwoodjs#10015) fix(RSC/SSR): pass CLI options through to apiServerHandler (redwoodjs#10012) 7.0 RC: Remove hardcoded check for `session.id` (redwoodjs#10013) Spelling fix in what-is-redwood.md (redwoodjs#10011) Typos in realtime.md (redwoodjs#10010) RSC: Server cell smoke tests (redwoodjs#10008) RSC: test-project EmptyUser 'use client' cell (redwoodjs#10007) RSC: babel-plugin-redwood-cell remove redundant reset (redwoodjs#10006) chore(deps): Upgrade to yarn v4.1.0 (redwoodjs#10002) fix(docs): Spelling of `data-migrate` command (redwoodjs#10003) docs: add aliases fo `type-check` command (redwoodjs#10004) RSC: Insert 'use client' in scaffolded components (redwoodjs#9998) fix(telemetry): Fix 'destroy' spelling (redwoodjs#10000) chore(jsdocs): Fix jsdoc formatting for hover help (redwoodjs#9999) bug: Update setupHandler.ts firebase version (redwoodjs#9997) ...
Problem
The current
rw-serve-fe
which is used when you have SSR or RSC enabled does not serve static assets likerobots.txt
or other files such as fonts, images etc which are placed inweb/dist
by theyarn rw build
process.This became apparent when I was upgrading the badge app example to the latest canary. The current behaviour is:
Whereas the expected behaviour (and the behaviour introduced by the changes here) is:
Changes
.default
for the build manifest console logging.Notes
I'm not certain this is the perfect way of doing this but it appears to match the behaviour we support in the non-rsc/ssr version of serve which registers a handler for static assets covering the full
dist
folder.I added this as "next-release" just because it felt that way to me but this could be considered a "next-release-patch". Happy for it to be changed.