4

I have an Angular 4 app, and I want it to point to a different URL for the backend (which is a java/spring app). When I had this problem on my localhost (it not being able to connect to my locally stood up backend) - I fixed it by adding this proxy.conf.json code (specifically the /api and /auth):

{
  "/api/*": {
    "target": "http://[::1]:8080",
    "secure": false
  },
  "/auth/*": {
    "target": "http://[::1]:8080",
    "secure": false
  },
  "*": {
    "target": "http://localhost:8080",
    "secure": false,
    "loglevel": "debug"
  }
}

I now want to test this by pulling against my backend stoodup as a pod in a Rancher environment. I try to have it point to the right backend code via the below changes:

{
  "/api/*": {
    "target": "https://fake-app1.my-fake-url.com",
    "secure": false
  },
  "/auth/*": {
    "target": "https://fake-app1.my-fake-url.com",
    "secure": false
  },
  "*": {
    "target": "https://fake-app1.my-fake-url.com",
    "secure": false,
    "loglevel": "debug"
  }
}

But when I look at the browser console it still shows up as going to localhost:8080 for API calls. Do I need to change anything else?

ruth
  • 29,535
  • 4
  • 30
  • 57
Stormy Weather
  • 295
  • 1
  • 4
  • 12

3 Answers3

1

Change this in webpack.dev.js: SERVER_API_URL: ""`

Mike K.
  • 543
  • 3
  • 14
  • 46
0

Here is what I changed for JHipster version 5.1.0:

webpack/webpack.dev.js

...
   devServer:
     proxy:[{
       target: 'http://127.0.0.1:8081'
     }]
SidMorad
  • 954
  • 12
  • 19
0

Have you tried setting changeOrigin to true? Looks like it might be needed if the backend is on a different host than the front end?

"changeOrigin": true: If you need to access a backend that is not on localhost or when you’re using some virtual proxies (such as configured with Apache2) on your backend set it to true.

See

Adam Wise
  • 2,043
  • 20
  • 17