Trying to configure a proxy along with ng serve

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of mmargozzi mmargozzi 5 days, 9 hours ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #544663 Reply
    Profile photo of mmargozzi
    mmargozzi
    Participant

    After reading the below article, I wanted to set up a proxy so I can redirect REST calls to a backend not running locally on my dev box. It is true that ng serve seems to ignore the –proxy-config.

    From a command line I ran npm run and it does work. How can I configure the IDE to work with the proxy?
    It seems like if I could tell it to start with npm start rather than ng serve it might work.

    I was unable to find a related posting here. Surely someone has already solved this issue.

    https://stackoverflow.com/questions/37172928/angular-cli-server-how-to-proxy-api-requests-to-another-server

    #544763 Reply
    Profile photo of support-swapna
    support-swapna
    Moderator

    mmargozzi,

    Apologies for the delayed reply. I have escalated this query to the dev team. They will get back to you soon.

    –Swapna
    MyEclipse Support

    #544768 Reply
    Profile photo of Brian Fernandes
    Brian Fernandes
    Moderator

    mmargozzi,

    What we do is convert the settings on the Eclipse proxy preference page (Window > Preferences > General > Network Connections) into NPM proxy settings in memory. The npm calls are then proxied through these settings.

    This applies to all npm commands executed from within the IDE. Can you try adding your proxy settings there & let us know if it works?

    #544773 Reply
    Profile photo of mmargozzi
    mmargozzi
    Participant

    Well, I tried my best to follow your suggestion. Here is what I did. it seems to have NO effect.
    See attachment.

    Attachments:
    You must be logged in to view attached files.
    #544784 Reply
    Profile photo of Brian Fernandes
    Brian Fernandes
    Moderator

    I think I may have misunderstood what you were trying to do, apologies.

    Bring up the context menu on your application in the Servers view and choose Properties (see attached screenshot). In the resulting dialog, there’s an area that allows you to specify custom ng serve command arguments. I guess you could add the --proxy-config switch there, pointing to the right configuration?

    Attachments:
    You must be logged in to view attached files.
    #544792 Reply
    Profile photo of mmargozzi
    mmargozzi
    Participant

    OK, this is what I was looking for and it worked. Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Trying to configure a proxy along with ng serve