Closed Shamshiel closed 9 months ago
Hello 👋 @Shamshiel
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
I think the issue is that the code uses a non-exported REQUEST
InjectionToken, so providing the request under the string token 'REQUEST'
won't work to populate it.
@Shamshiel Can you share stackblitz reproduction?
@Shamshiel create new issue by following issue template and stackblitz reproduction
Any news in this problem? I can't access my cookies in the SSR of Angular 17.
Any news in this problem? I can't access my cookies in the SSR of Angular 17.
No. I am able to access them in my code. Can you share an example where you can't access them?
When you use a Guard and try to access the cookie when does SSR, it returns null the "req" Injection.
Any news in this problem
@oriollpz @zozjo Can anyone of you try share a StackBlitz example of tis problem?
@oriollpz @zozjo @Shamshiel @jnizet Can you try version 17.0.1-rc.1
and see if it fixes the issue?
I haven't tried your RC but I fixed the issue by just copying your SsrCookieService
in my project and exporting the REQUEST like this:
export const REQUEST = new InjectionToken<Request>('REQUEST');
and then importing it in the server.ts like this:
import { REQUEST } from './src/app/services/ssr-cookie.service';
So the issue is that in v17.0.0 of this library the InjectionToken is not exported. Just using the token 'REQUEST' does not work. I guess the RC would work if SSR_REQUEST is the actual exported InjectionToken for REQUEST.
Fixed in version 17.0.1
Fixed in version
17.0.1
Hi! I am facing the same error.
I am using:
"@angular/ssr":"~17.0.0", "ngx-cookie-service-ssr": "^17.0.1"
I did
console.log(this.cookieService.get('lang'))
and got:
Can you help me please. I have attached the screenshots.
@xalidevxx See updated docs https://github.com/stevermeister/ngx-cookie-service?tab=readme-ov-file#server-side-rendering. You need to import REQUEST
@xalidevxx See updated docs https://github.com/stevermeister/ngx-cookie-service?tab=readme-ov-file#server-side-rendering. You need to import
REQUEST
I added the request as in the documentation. Then I built the project and run the production version locally. I output cookieService.get('lang') in app.component.html.
As a result:
I expect the server version and browser version to should be the same.
Is this how it should work?
@xalidevxx See updated docs https://github.com/stevermeister/ngx-cookie-service?tab=readme-ov-file#server-side-rendering. You need to import
REQUEST
Hi! Can you help me please?
News about this issue? Still got same behaviour on latest release
News about this issue? Still got same behaviour on latest release
Hi! I didn't find a solution and left it like that.
All, I am looking at this. Stay tuned.
Might be related https://github.com/angular/angular-cli/issues/26323
is there any news guys? I'm facing the same issue
Stumbled upon this issue as well. would be amazing to have it fixed :)
Any fixes yet?
Either I'm doing something wrong or cookies can't be retrieved from request headers via the SsrCookieService. It seems that SsrCookieService is not able to retrieve the request from the providers.
I have the server.ts and my guard like described below but the bearer token can't be retrieved. I checked the incoming request in the server and the cookie is available in the header. So I assume the request is for some reason not correctly provided to the SsrCookieService.
Is that a bug or am I doing something wrong?
server.ts
Guard
Specifications