Description
Which @angular/* package(s) are the source of the bug?
common
Is this a regression?
Yes
Description
-
My backend API resides at
api.domain.com
-
I'm using the path
//api.domain.com/api/product
for fetching data within the Angular app. This approach is necessary because withXsrfConfiguration() doesn't function correctly with absolute paths (e.g., https://api.domain.com/api/product). -
While this relative path (
//api.domain.com/api/product
) works properly during runtime, it fails to resolve correctly during SSG build time. This results in no data for the product prerendered page. -
Interestingly, absolute paths do work during SSG, but they prevent the use of withXsrfConfiguration, which is crucial for Cross-Site Request Forgery (CSRF) protection.
-
Is there a known workaround to address the incompatibility between withXsrfConfiguration and relative paths in SSG in Angular 17.
-
Also, if we use proxies and have a relative URL like
/api/product
, this might work with withXsrfConfiguration but not in SSG.
Conclusion
- Relative URLs like
// (protocol-relative) and / (root-relative)
work with withXsrfConfiguration but not in SSG and Absolute URLs work in SSG but not with withXsrfConfiguration.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 17.3.2
Node: 21.7.1 (Unsupported)
Package Manager: npm 10.5.2
OS: win32 x64
Angular: 17.3.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, platform-browser, platform-browser-dynamic
... platform-server, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1703.2
@angular-devkit/build-angular 17.3.2
@angular-devkit/core 17.3.2
@angular-devkit/schematics 17.3.2
@angular/cli 17.3.2
@angular/ssr 17.3.2
@schematics/angular 17.3.2
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.3
Anything else?
No response