Static GitHub Issues

[1719] proxy not work in nginx server

prev: how to use the url-loader?
next: [NOT AN ISSUE|QUESTION] How to load a non VueJS plugin ?

Nuxtjs: 1.0.0 RC11 = @nuxtjs/proxy : latest

I had build my spa page very well, and there's a third party API request using axios in my page. When i run it from localmachine , everything is fine. But after i move the generate files using nuxt generate into nginx server. I found that the proxy request cannot parse with 404 returned.

the proxy i had configured in my nuxt.config.js file like below:

 modules: [
    ['@nuxtjs/google-analytics', { ua: 'UA-78501857-4' }],
    '@nuxtjs/axios',
    '@nuxtjs/proxy'
  ],
  axios: { debug: true },
  proxy: {
    // /api/test1/test2  -> http://www.toutiao.com/api/test1/test2

    '/api': {
      target: 'http://www.toutiao.com',
      changeOrigin: true,             // for vhosted sites, changes host header to match to target's host
      logLevel: 'debug'
    }
  },
  1. The axios request url is : http://www.toutiao.com/api/pc/feed/?min_behot_time=0&category=all&utm_source=toutiao&widen=1&tadrequire=true&as=A105A9CB66F96E6&cp=59B609C66E464E1

  2. The proxy url had become: http://localhost:3030/api/pc/feed/?min_behot_time=0&category=all&utm_source=toutiao&widen=1&tadrequire=true&as=A105A9CB66F96E6&cp=59B609C66E464E1
  3. In nginx server I saw the request is http://servername.com/api/pc/feed/?min_behot_time=0&category=all&utm_source=toutiao&widen=1&tadrequire=true&as=A105A9CB66F96E6&cp=59B609C66E464E1 , but it returned as 404.
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1541">#c1541</a>)</em></sub></div>