vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.5k stars 4.77k forks source link

config.devServer.proxy doesn't proxy, shows NotFound.vue #1550

Open THAlpha opened 5 years ago

THAlpha commented 5 years ago

Bug report

Version Tried in 0.14.11 and 1.0.0-alpha.47

Steps to reproduce

module.exports = {
  configureWebpack: (config, isServer) => {
    config.devServer = {
      proxy: {
        '^/auth': {
          target: 'http://localhost:7070',
          ws: true,
          changeOrigin: true
        }
      }
    };
  }
};

What is expected?

Should serve the contents of http://localhost:7070/auth/{anything} on port 8080

What is actually happening?

Displaying 404 page (NotFound.vue) within vuepress + vue router

Other relevant information

THAlpha commented 5 years ago

I have created a sample repo that demonstrates this issue:

https://github.com/THAlpha/vuepress-proxy-test

coder-xiaotian commented 5 years ago

I encountered this problem too! I don't know how to fix it.

coder-xiaotian commented 5 years ago

I have solved the problem! I update the version of vuepress to 1.0.0-alpha.48 and then figure it out. I find the solution in this Issue #1195.

config.js: image

my9074 commented 5 years ago

@775146061 I update vuepress to1.0.0-rc.1. And using your above configuration,proxy the ajax, but still does not take effect. At 404

config.js:

image

image

coder-xiaotian commented 5 years ago

@my9074 我上传了demo https://github.com/775146061/vuepressProxyDemo,我觉得可能是你哪儿配置错了,也可能是1.0.0-rc.1这个版本的问题,因为我试了一下用这个版本返回的http状态码是304,然后我升级到1.0.1就好了