Angular-cli: proxy config is not working after build the code by ng build

Created on 6 Feb 2017  路  9Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Most helpful comment

I feel like I need to chime in here and say just how LUDICROUS this is. Honestly I'm beside myself that this is the "accepted" answer. Who the hell makes their Dev workflow THAT MUCH different from Prod? I mean seriously - there's no way to seamlessly recreate that sort of a proxy, so you've completely left ANY developer who's used this (awesome) feature out in the cold. We've used that feature extensively to get around CORS, so basically you're saying it's OK and "the plan" to make it so Angular can't use ANY remote APIs out of the box, even though this feature exists? This has to be the absolute dumbest and most frustrating thing I've ever seen, and that's counting how frustrated I was going from AngularJS to Angular 2+. Just ... Shame.

All 9 comments

proxy config is not working after build the code by ng build

The proxy configuration is intended to proxy calls when running the dev server via ng serve. After you run ng build you are responsible for the web server and its configurations when you run/host the output in the dist dir.

This is a misunderstanding of the proxy functionality... closing.

I am consuming rest api. So I need proxy config after build the code

@uyadav0001 Were you able to resolve this. I am also having the same issue.

In order to aviod CORS errors, I set up the proxy similar to yours. When I use ng build, it totally ignores the start line in the package.json that launches the proxy with npm start

Any update here ?

@ashwinpatiljumia, @Brocco has mentioned above the proxy configuration is strictly just for local development. When you build, you have to configure the server serving the app to proxy the requests.

I feel like I need to chime in here and say just how LUDICROUS this is. Honestly I'm beside myself that this is the "accepted" answer. Who the hell makes their Dev workflow THAT MUCH different from Prod? I mean seriously - there's no way to seamlessly recreate that sort of a proxy, so you've completely left ANY developer who's used this (awesome) feature out in the cold. We've used that feature extensively to get around CORS, so basically you're saying it's OK and "the plan" to make it so Angular can't use ANY remote APIs out of the box, even though this feature exists? This has to be the absolute dumbest and most frustrating thing I've ever seen, and that's counting how frustrated I was going from AngularJS to Angular 2+. Just ... Shame.

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hareeshav picture hareeshav  路  3Comments

sysmat picture sysmat  路  3Comments

rwillmer picture rwillmer  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

5amfung picture 5amfung  路  3Comments