Skip to content

Feature request: allow CORS on local dev server #803

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

Closed
wholladay opened this issue May 17, 2016 · 12 comments
Closed

Feature request: allow CORS on local dev server #803

wholladay opened this issue May 17, 2016 · 12 comments
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@wholladay
Copy link

  1. OS? Mac OSX (El Capitan?)
  2. Versions.
    angular-cli: 1.0.0-beta.1
    node: 5.10.0
    os: darwin x64
  3. Repro steps. I'm running a Spring-Boot server as my RESTful API and to serve up the initial html page. The html page then gets the angular app from a CDN. The Angular cli server acts like the CDN while we are developing. Both Spring and Angular cli are running on my local machine (with different ports). When the call to System.import() is made, I get a CORS error from the browser.
  4. The log given by the failure.
    XMLHttpRequest cannot load http://localhost:4200/system-config.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
    zone.js:323 Error: Error: XHR error loading http://localhost:4200/system-config.js(…)
  5. Mention any other details that might be useful.
    I'm sure there must be a way to do this, but I've tried everything I can think of.
@igorantolic
Copy link

+1 vote for enabling to set custom Access-Control-Allow-Origin parameter for ng serve

@machi1990
Copy link

To be able to make CORS http request I had to use the "--proxy" i.e ng server --proxy http://localhost:8080.

@wholladay
Copy link
Author

I actually solved this issue by using the ember-cli-cors add on. All you have to do is install it using the ng command like so:
ng install ember-cli-cors

@igorantolic
Copy link

ng install ember-cli-cors
didnt help. What am I missing?

@Brocco
Copy link
Contributor

Brocco commented May 24, 2016

@wholladay I presume that you meant:

npm install ember-cli-cors

and not

ng install ember-cli-cors?

@cotomas can you please try using npm install?

@wholladay
Copy link
Author

@Brocco No, I first tried npm install ember-cli-cors and that did not work. When I ran ng install ember-cli-cors it did the trick for me.

@filipesilva filipesilva added feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Jun 3, 2016
@ghost
Copy link

ghost commented Jun 7, 2016

+1

@wholladay did you configure anything after ng install ember-cli-cors ?
Or change the ng serve command at all?

It looks like all that did was install the npm package in package.json devDependencies for "ember-cli-cors". How does ng serve know about it after it is installed?

In my scenario I am trying to port an Angular 1 app where in Dev we had to run "C:\..\chrome.exe" --disable-web-security to access a SharePoint oData source. We also have to login to SharePoint first to get authenticated. Eventually the app is deployed to SharePoint and all that is no longer an issue. It used to work in Angular 1, would be nice to have it with angular-cli as well.

@maxailloud
Copy link

I tried ng install ember-cli-corsand nothing changed for me.
Is there an additional step to do to make it work?

@wholladay
Copy link
Author

@jmb-mage I did not configure anything differently that I can remember, not did I change the ng serve command. It just kind of... well, started working and I moved on to other issues.

@ghost
Copy link

ghost commented Jul 20, 2016

@wholladay as a workaround I ran the npm http-server onto the public or dist folder directly.

It has these attributes:

http-server -o --cors

@filipesilva
Copy link
Contributor

Superseded by #2872, as this was for a pre-webpack version of the CLI.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Issue that requests a new feature P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

6 participants