Nuxt.js: webpack proxy not work

Created on 6 Mar 2017  ·  16Comments  ·  Source: nuxt/nuxt.js

build: {
    extend (config, ctx) {
      if (!ctx.isClient) {
        config.devServer = {
          proxy: {
             '/api/*': {
              target: 'http://127.0.0.1:8080/',
              secure: false
             }
          }
        }
       } 
    }
  }

This question is available on Nuxt.js community (#c305)
help-wanted

Most helpful comment

英文不好啊。English is not good
I want to use webpack to achieve the function of proxy API。
Nuxt configuration webpack using extend。
I configured as shown above。
But API has been rendered by nuxt。404

All 16 comments

Can you explain more about your issue?

英文不好啊。English is not good
I want to use webpack to achieve the function of proxy API。
Nuxt configuration webpack using extend。
I configured as shown above。
But API has been rendered by nuxt。404

不配置https 试试

不行啊,这里配置有问题,但是不是https的问题。
No, ah, this configuration has a problem, but not a HTTPS problem

英文都是金山翻译的。哈哈

解决了没?我也在研究咋配置

有解决的吗 求参考。。

@Duuuuuke 我之前是需要跨域才来这,后来才发现根本就不用配置代理,通过express去请求JAVA后端,因为已经脱离了浏览器就没有跨域的问题了。

I feel like still struggling with setting up webpack proxy. Although we can use the express backend to send request to other services but seems like a redundant task ? Is the webpack proxy is still working @longzhaobi @alexchopin

I don't think it is working, the request seems to be handled by nuxt always. I even tried Nuxt's proxy module and it was useless for custom matchings >.<

So, is there any other solution?

@longzhaobi
我是纯静态网站,请求后台就会跨域,怎么弄

My case:
In server/index.js

import proxy from 'http-proxy-middleware'
...
if (config.dev) {
  router.all(/\.do$/, proxy({
    target: 'http://localhost:8082/portal/',
    // changeOrigin: true,
    ws: true
  }))
}

已解决(solved):
look at this:
https://github.com/gauseen/nuxt-proxy

还是要先把洋文学好了来.只会哑巴英语真的有点恼火...哎

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gary149 picture gary149  ·  3Comments

lazycrazy picture lazycrazy  ·  3Comments

surmon-china picture surmon-china  ·  3Comments

jaredreich picture jaredreich  ·  3Comments

danieloprado picture danieloprado  ·  3Comments