-
Notifications
You must be signed in to change notification settings - Fork 12k
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 13 CORS on localhost #22992
Comments
The error seems to indicate that you are trying to access a different host Can you please provide the configuration the extract of |
Hello, thanks for the prompt answer. Here is the angular.json and package.json and extra-webpack config that we are using in our app. Just to mention it once again, we did test this on new app, where the angular json and package json are the default ones that the cli provides, without using custom webpack etc, and still got the same issue. angular.json
package.json
webpack config
|
Is there any additional work we can do to further investigate this issue? |
When using angular-cli/packages/angular_devkit/build_angular/src/webpack/configs/dev-server.ts Lines 277 to 281 in 1c634cd
Providing a reproduction would definitly help us investigate and resolve the issue. A good way to make a minimal repro is to create a new app via This might be related to your directory structure so its really important to get an accurate repro to diagnose this. |
I'm sorry, but we can't reproduce the problem following the instructions you provided. If the problem persists, please open a new issue following our submission guidelines. A good way to make a minimal repro is to create a new app via |
@pgarzina |
Unfortunately we still have not found the solution. Its hard to make a minima repro since the issue is related to accessing resources from an outside domain that are served on localhost. So putting it up on stackblitz does not really help. Plus we have to setup single-spa to reproduce the issue, or make a similar setup where another domain is accessing localhost. As we did zero code changes other than upgrading from angular 12 to angular 13 it seems to indicate that the issue lies somewhere in angular or how they setup/use webpack or whatnot. We plan to investigate it a bit further as we are now stuck on angular 12 because of this, so if we find anything ill paste it here. |
We did have other similar reports recently and appears that this issue only occurs when using occurs when using the non official |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
After updating Angular 12 to Angular 13 we are no longer able to access our app served on localhost from outside of it, the request is being blocked by CORS.
this is what worked in Angular 12
ng s --project app-search --disable-host-check --port 4207 --deploy-url https://localhost:4207/ --ssl --public-host https://localhost:4207/
and stopped working in Angular 13.
When in development mode we are accessing our https://localhost:4207 app from https://app-staging.cognism.com/
We were looking into the docs around Webpack 4 and Webpack 5 and we can see that the disableHostCheck flag is removed from webpack 5 doc but is in webpack 4 docs. We tried playing around with disable host check and allowed hosts passing it to ng serve per official docs (https://angular.io/cli/serve) but with no luck.
The reason why we need to access localhost is we are using single-spa as a javascript router for front-end microservices. We also tried it on a clean Angular 13 project without any modifications but we get the same behavior.
Not quite sure if this is a bug or do the flags have to be passed in a different way to enable the same behavior that we had before.
Thank you
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: