8

If I'm serving a react application with npm install -g serve; serve -s build, is it possible to also have a location proxy?

Ex: any requests to https://example.com/api/* will be redirected to https://example.com:8000/api/*

cclloyd
  • 8,171
  • 16
  • 57
  • 104

1 Answers1

2

You can try proxy in package.json

"proxy": {
    "/api": {
      "target": "http://localhost:3001"
    },
    "/assets": {
      "target": "http://localhost:3001"
    }
  },

You may also check environment config options here if above does not solve: https://docs.npmjs.com/misc/config#proxy

Rikin
  • 5,351
  • 2
  • 15
  • 22