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

Custom headers in defineRoute possible? #2339

Closed
vicary opened this issue Feb 26, 2024 · 2 comments
Closed

Custom headers in defineRoute possible? #2339

vicary opened this issue Feb 26, 2024 · 2 comments
Labels

Comments

@vicary
Copy link

vicary commented Feb 26, 2024

With defineRoute being a really convenient method for type inference, I almost exclusively use this helper method.

I found it falls short for pages with forms, where it is supposed to go stale when navigated away, a common practise would be adding Cache-Control: no-cache, no-store, must-revalidate.

Is it possible to allow custom headers when returning a component from the helper?

@marvinhagemeister
Copy link
Collaborator

Headers are set in so called Handler functions in Fresh that are executed before any rendering happens. See https://fresh.deno.dev/docs/getting-started/custom-handlers

@vicary
Copy link
Author

vicary commented Mar 13, 2024

Note to self: useContext breaks (#983) when exporting defineRoute with an async callback, while exporting a sync FunctionComponent works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants