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

[Angular 18] ngx-cookie-service-ssr get returns empty string even if cookie is available #326

Closed
apappas1129 opened this issue Oct 8, 2024 · 5 comments

Comments

@apappas1129
Copy link

apappas1129 commented Oct 8, 2024

Describe the bug

It seems that this service inherits the same issue reported here where Angular 18's ng serve is not using server.ts which means that adding the providers { provide: SSR_REQUEST, useValue: req } and { provide: 'RESPONSE', useValue: res } won't serve its purpose.

I tried building and serving the dist/<project>/server/server.mjs and it did get the existing cookie successfully.

Steps to Reproduce

  1. Use Angular 18
  2. install ngx-cookie-service-ssr and follow instructions in readme regarding adding of the providers in the express server
  3. ng serve and test .get method (make sure cookie exists)

Expected behaviour

  1. should work with ng serve
  2. should work seemlessly on the client and ssr runtime

What version of the library you see this issue?

"ngx-cookie-service-ssr": "^18.0.0"

What version of Angular are you using?

Angular 18

Screenshots

No response

Desktop? Please complete the following information

No response

Mobile? Please complete the following information

No response

Anything else?

No response

Copy link

github-actions bot commented Oct 8, 2024

Hello 👋 @apappas1129
Thank you for raising an issue. We will investigate into the issue and get back to you as soon as possible. Please make sure you have given us as much context as possible.
Feel free to raise a PR if you can fix the issue

@apappas1129
Copy link
Author

apappas1129 commented Oct 9, 2024

Upgrading to v19 pre-release solved the issue. ATTOW, ng update @angular/cli @angular/core --next=true --force pulled in version 19.0.0-next.9 and ng serve now successfully "provides" the providers defined in the server.ts CommonEngine.render.

@blakeoxx
Copy link

blakeoxx commented Oct 9, 2024

Thanks for the feedback. Unfortunately, I'm not sure there's a path forward for fixing ng serve use cases. As I understand it, ng serve is intended for testing your client-side application, which means the server-side architect isn't even used by default. Webpack stands up a minimal expressJS instance just so your browser has a local server to get the built files from.

While I'd say this is somewhat intended behavior, it's definitely a little misleading. I'm happy to hear NG19's default architect configuration fixes this though.

@pavankjadda
Copy link
Collaborator

Upgrading to v19 pre-release solved the issue. ATTOW, ng update @angular/cli @angular/core --next=true --force pulled in version 19.0.0-next.9 and ng serve now successfully "provides" the providers defined in the server.ts CommonEngine.render.

Closing as per this

@apappas1129
Copy link
Author

Upgrading to v19 pre-release solved the issue. ATTOW, ng update @angular/cli @angular/core --next=true --force pulled in version 19.0.0-next.9 and ng serve now successfully "provides" the providers defined in the server.ts CommonEngine.render.

Closing as per this

Still need to push an update to the documentation to write a disclaimer that Angular 18 is not fully supported.

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

No branches or pull requests

3 participants