Loading an assets file with relative path
See original GitHub issue- I’m submitting a …
- [X ] bug report
- [ ] feature request
- [ ] support request
- What modules are related to this Issue?
- [ ] aspnetcore-engine
- [x ] express-engine
- [ ] hapi-engine
-
Do you want to request a feature or report a bug? Bug
-
What is the current behavior? When trying to load assets files (json) from the assets folder with a relative path, the Universal version of our application fails to load them. The client version works fine. The files are intended to load via a service which is initiated via APP_INITIALIZER. The service starts up and works fine, just the files cant be loaded. Unless you load them with an absolute path (http://localhost:4000/assets…)
-
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem by creating a github repo.
- Create a service to load json-files via HttpClient.
- Call it via APP_INITIALIZER
- Turn on Universal according to https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/universal-rendering.md
-
What is the expected behavior? The expected behaviour would be that the files load as they do in the client version
-
Please tell us about your environment:
- Angular version: 5.0
- Browser: [all]
- OS: [Mac OS X | Windows ]
- Platform: [all | NodeJs ]
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:15 (2 by maintainers)
@stasberkov This works great with the Express server side rendering. However, it does not work for
prerender
. In that caseREQUEST
is empty, as there seem to be no requests (see https://github.com/angular/universal/issues/2147#issuecomment-852775977).@Toxicable just to add, that if you are using the prerender api then, you need to load the full express server to be able to use the
HttpInterceptor
hack, because it won’t work otherwise. Just like @OCCGU example.