-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Possibility to create cookie on server side #266
Comments
Hello 👋 @Ben555555 |
@Ben555555 I don't think this is possible. The cookies are set with syntax
This should be part of the response from server, from API request |
@pavankjadda It is as you can see in my example:
It is also implemented like this in the following library, which unfortunately is not maintained anymore: https://github.com/salemdar/ngx-cookie/blob/master/projects/ngx-cookie-backend/src/lib/cookie-backend-writer.service.ts Without this feature it's not possible to modify or add a cookie on server side which is a very useful feature. |
Interesting, let me take a look. Haven't spent much on this so far |
@pavankjadda is this issue still looking for contributions? I'm available to craft a PR if so. |
Sure. Go ahed |
The Angular team closed my issue saying that cookies do not exist on the server side and the problem is in the way this library is operating. Could you help with my problem? |
I am on vacation can't check it until next week. |
@GkIgor the Angular team is correct. You need to use the If switching out the packages still doesn't get you any closer, I'd recommend opening a separate issue for Pavan to look at when he returns. This doesn't seem to be related to the issue stated here of not being able to write cookies during SSR. |
Just in case, the problem may be related to the new ssr in angular 17. The current dev server does not use the server.ts file so any providers or changes made to that file won't work on the dev server. |
Resolves stevermeister#266 Cherry-picked from commit 123b698
Resolves stevermeister#266 Cherry-picked from commit 123b698
This repo doesn't maintain backport versions, but I had a need for them to support Angular 16, 17, and 18 projects I have. For anyone else interested, I made a repo to store built artifacts for these backports. Hopefully it helps as a temporary solution: |
See #320 (comment) |
Is your feature request related to a problem? Please describe
Is it possible to create a cookie on the server side?
When I try this, the cookie does not seem to be attached in the response that is coming from the server:
Describe the solution you'd like
cookieService.set should also send a "Set-Cookie" header in the response.
Describe alternatives you've considered
TransferState
Additional context
A possible implementation could look like this:
The text was updated successfully, but these errors were encountered: