Failed to load url /some/url/path (resolve id: /some/url/path). Does the file exist?
Command
serve
Is this a regression?
- [ ] Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Environment: Angular v17 with vite
When using "proxyConfig": "src/proxy.conf.json" option in angular.json and adding some proxy path URL to load the js script in index.html while loading the application it shows the following error message in terminal
Failed to load url /some/url/path (resolve id: /some/url/path). Does the file exist?
proxy.conf.json
{
"/some": {
"target": "https://example.com/some",
"pathRewrite": {
"^/some": ""
},
"secure": false,
"changeOrigin": true
}
}
index.html
<script
async
src="/some/test.bundle.min.js"
type="text/javascript"
></script>
It does not stop the dev server. it works as expected and all files are loaded correctly.
Note: It does not show such an error message for CSS files!
Minimal Reproduction
It is reproducible in new projects and also
- Create new angular v17 apps
- Add proxy config
- Add proxied URL to load
jsscript inindex.html - Run
ng serve - Load the app in the browser
Exception or Error
It should consider proxy config for index.html and not print this error message
Your Environment
Angular CLI: 17.0.0
Node: 18.18.2
Package Manager: npm 9.8.1
OS: linux x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1700.0 (cli-only)
@angular-devkit/core 17.0.0 (cli-only)
@angular-devkit/schematics 17.0.0 (cli-only)
@schematics/angular 17.0.0 (cli-only)
Anything else relevant?
No response
/some does not match /some/test.bundle.min.js as such the 404 is legit in this case and the fact that worked under webpack-dev-server seems to be incorrect.
Solution is to update "/some" to "/some/**/*"
It is not throwing any 404 error in the browser. it is working fine but in terminal it shows the Failed to load url error message
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
Minimal repo: https://github.com/AmitRDesai/ng-proxy-config-issue
the same is happening to after upgrading from Angular 16 to Angular 17.
It seems that with Angular 17, the paths aliases specified within tsconfig.json are not considered/resolved by the application builder.
Giving a similar error https://github.com/angular/angular-cli/issues/26394#issuecomment-1817346465
Example of tsconfig.json
{
...
"compilerOptions": {
"paths": {
"@common/*": ["app/common/*"],
"@components": ["app/components/*"]
}
...
}
}
It got resolved in v18
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.