-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
add ability to pass middleware to @astrojs/node when using standalone… #11516
add ability to pass middleware to @astrojs/node when using standalone… #11516
Conversation
🦋 Changeset detectedLatest commit: c712fbe The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
9a04a07
to
34ea7cc
Compare
2c48b81
to
fdc526b
Compare
50001fc
to
2e2829c
Compare
28c42ca
to
a0e5aa0
Compare
I'm not sure I understand the usecase. Why can't you use |
Its mostly for use-cases where we could benefit from using publicly available |
We're not convinced by the usecase to be honest. We think middleware mode is exactly designed for what you want. You said you don't want the overhead of express but standalone mode is not meant to be a full fledge web server either. I'm sure you can find lighter alternatives than express if the bloat is what you're afraid of. Unless you have more arguments, I'm afraid we'll have to close the PR |
Astro has middleware already, so adding a second way to add middleware that only works in SSR doesn't seem like a good choice for us. |
Add option to pass middleware to
@astrojs/node
when using standalone mode.Changes
standaloneMiddleware
file as a parameterstandaloneMiddleware
param is passed, @astrojs/node (in standalone mode) will attempt to load the middleware's and run them.combined
list of middleware's that need to run.standaloneMiddleware
option is passed.Testing
I've tested this using a standalone app. Also added tests. Below are the sample changes.
astro.config.mjs
node_middleware.js
Docs
Opened PR for updating docs in
@astrojs/node
integrations guidewithastro/docs#8789