nuxt-community / proxy-module

The one-liner node.js http-proxy middleware solution for Nuxt 2 using http-proxy-middleware
MIT License
413 stars 26 forks source link

Unable to call Proxy API on server #115

Open html-helpers opened 1 year ago

html-helpers commented 1 year ago

Hi Team,

I am not able to call proxy url which I setup in target field in nuxt.config.js.

Sample code:

Nuxt.config.js:

modules: [ '@nuxtjs/proxy' ], proxy: { '/api/ :{ target: 'some external API Endpoint / URL', pathRewrite: { '^/api/' : '/' }, changeOrigin: true } }

Above setup working fine in localhost, but when I create dist folder and deploy to server and run from the server, it is actually tried to fetch resource from server, not from proxy end point.

Let me know how to fix this issue, so my proxy URL will start working on server.

joseehilton147 commented 1 year ago

same problem

CHEWX commented 1 year ago

Same problem here too. Works locally, not in production. I'm using mode: 'spa' if it helps.

CHEWX commented 1 year ago

Found the problem for me, if using SPA, you cannot run npm run build, it needs to be dev | start on a node.js server. As such it will not work for me.