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

New setting headersResponse #1803

Open
nitedani opened this issue Aug 13, 2024 · 3 comments
Open

New setting headersResponse #1803

nitedani opened this issue Aug 13, 2024 · 3 comments
Labels
enhancement ✨ New feature or request

Comments

@nitedani
Copy link
Member

nitedani commented Aug 13, 2024

Description

I'd like the ability to set response headers in a hook/config.

This would be useful for, for example https://github.com/magne4000/vite-plugin-vercel, so it could allow users to set cache-control headers in their +config.js file, to leverage Vercels edge cache.

I think headers could be a vike core config, for example:

// +config.js
export default {
	headers: { "Cache-Control" : "s-maxage=15" }
}
@brillout
Copy link
Member

Agreed. Although I'd name it headersResponse (because of pageContext.headers and #1268).

How much of a priority is it?

@brillout brillout changed the title Ability to set response headers in a hook New setting headersResponse Aug 14, 2024
@gnardini
Copy link

(I think) related to this I'd like to be able to set a cookie from a +data.ts file.

@brillout
Copy link
Member

@gnardini Indeed with useConfig() it would be a nice addition.

In the meantime, how about the following?

// +data.js

export default (pageContext) => {
  pageContext.theCookieIWantToadd = '...'
}

Then access it at your renderPage() integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants