feat: refactor edgemiddleware into middlewareMode adapter feature#15495
feat: refactor edgemiddleware into middlewareMode adapter feature#15495leekeh wants to merge 26 commits intowithastro:mainfrom
edgemiddleware into middlewareMode adapter feature#15495Conversation
🦋 Changeset detectedLatest commit: 804801e 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 |
middlewareMode feature in the coreedgemiddleware into core middlewareMode feature
edgemiddleware into core middlewareMode featureedgemiddleware into middlewareMode adapter feature
ematipico
left a comment
There was a problem hiding this comment.
I love where this is heading! As for the docs, developers are responsible to update/add the docs themselves, so you'll have to send a PR to the docs repository.
As for the requested changes, let's remove the options that were added to the cloudflare and node adapter.
As for the changeset, astro must be a minor because we're adding a new "feature", meaning a new option
|
Hi @leekeh ! Thanks for being so receptive to Ema's feedback! Just giving some more advice on the changeset from Astro Docs here! We have guidance and models to get you started in our Docs contributing docs: https://contribute.docs.astro.build/docs-for-code-changes/changesets/ Please take a look at this guide and see if you can match our format/style a little more closely. Then, I'm happy to come in and help you polish them up! The main idea is, you're giving people a new feature and we want to make sure that the changeset shows it off and hypes it up! That means making it clear who this is for, and why/how they might want to use it.. and why it's cool or what it unlocks! When it replaces something existing, we also want to be extra explicit about how to update their own project code, and what to look for to make sure they got it right. There are examples on that page that will give you an idea! I'll be checking back in later, but don't hesitate to ask questions in the mean time! |
Hi @sarah11918 :) |
sarah11918
left a comment
There was a problem hiding this comment.
Thanks, @leekeh , these changesets look great! I left some tiny comments for your consideration. They are very minor, but I always like to let people know what our typical style is because the more consistent we are, the easier it is for people to get used to our changelogs.
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
|
@ematipico Should the That's the only thing I spot still! |
|
Also commenting that the accompanying docs PR is approved, so docs is happy whenever this PR is ready! |
Ah yes, they should be minor too! |
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Changes
Refactor
edgeMiddlewareoption into a more genericmiddlewareMode, creating space for future options.edgeMiddlewarein core and all adaptersmiddlewareModeedgeMiddlewaretomiddlewareMode: edgefor backwards compatibilitymiddlewareModeto the SSR manifestContext
Currently, middleware runs on static pages during build, and on dynamic pages after build. There is the need to customize this behavior, specifically to run middleware on static pages, for example to add an authentication check.
Some adapters have a way to implement this using
edgeMiddleware, but this is not possible for all adapters, since not all environments support edge middleware. It would be better to have a generic way to define when middleware should run. We call this new optionmiddlewareMode.In this first PR, I'm focusing on preparing the configuration for these new features, without adding them yet. In a subsequent PR, implementations for
on-requestandalwaysoptions formiddlewareModewill be added."classic"(default)"always""on-request""edge"edgeMiddlewareconfig option.Related discussions:
Testing
Since this is a refactor that should not change any existing functionality, no new tests were added. Existing tests should pass.
Docs
withastro/docs#13277
/cc @withastro/maintainers-docs for feedback!