Skip to content
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

Middleware: unclear that reading cookies/headers behaviour #8264

Closed
thomasledoux1 opened this issue May 13, 2024 · 1 comment · Fixed by #8572
Closed

Middleware: unclear that reading cookies/headers behaviour #8264

thomasledoux1 opened this issue May 13, 2024 · 1 comment · Fixed by #8572
Labels
good first issue Good for newcomers help wanted Issues looking for someone to run with them! improve documentation Enhance existing documentation (e.g. add an example, improve description)

Comments

@thomasledoux1
Copy link
Contributor

📚 Subject area/topic

Middleware

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/guides/middleware/

📋 Description of content that is out-of-date or incorrect

At the moment in my opinion it is not clear that you can not read cookies/headers from the context in middleware when you are request a static page.
I'm not sure where exactly this information could be highlighted, but I couldn't figure this out from the existing docs.
I first created an issue in the astro repo withastro/astro#11023

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

@thomasledoux1 thomasledoux1 added the improve documentation Enhance existing documentation (e.g. add an example, improve description) label May 13, 2024
@sarah11918
Copy link
Member

Hi @thomasledoux1 ! The documentation that describes Cookies/Headers as an on-demand/SSR rendered feature is here: https://docs.astro.build/en/guides/server-side-rendering/#on-demand-rendering-features

We have actually been discussing internally that we don't have a (any? 😅 ) examples showing use of middleware in a static site, so we also haven't really documented well on that page the difference.

What would you think about adding to the original first sentence on the middleware page, something like:

Middleware allows you to intercept requests and responses and inject behaviors dynamically every time a page or endpoint is about to be rendered. This rendering occurs at build time for all prerendered pages, but occurs when the route is requested for pages rendered on demand, making additional SSR features like cookies and headers available.

Do you think that addresses the issue? If so, I'd be happy to receive a docs PR to that page!

@sarah11918 sarah11918 added good first issue Good for newcomers help wanted Issues looking for someone to run with them! labels Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Issues looking for someone to run with them! improve documentation Enhance existing documentation (e.g. add an example, improve description)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants