Closed SwapnilSoni1999 closed 4 years ago
I have the same problem and spent hours on it :pensive: . Did you figure it out @SwapnilSoni1999 ? If not maybe @chymz can give us a help :thinking: . All my axios requests don't reach my API server
Sorry for late response.
UVue doesn't use webpack dev server, that's why this configuration is ignored. Instead, you can create your own server plugin to use a http proxy middleware.
For example if you use default server adapter or express:
const { createProxyMiddleware } = require('http-proxy-middleware');
export default {
install(app) {
if (process.env.NODE_ENV !== 'production') {
const proxyOptions = {
target: 'https://api.example.com',
changeOrigin: true,
ws: true,
};
app.use('/api', createProxyMiddleware(proxyOptions));
}
}
}
And install it like explained here: https://universal-vue.github.io/docs/plugins/#server
Sorry for late response.
UVue doesn't use webpack dev server, that's why this configuration is ignored. Instead, you can create your own server plugin to use a http proxy middleware.
For example if you use default server adapter or express:
const { createProxyMiddleware } = require('http-proxy-middleware'); export default { install(app) { if (process.env.NODE_ENV !== 'production') { const proxyOptions = { target: 'https://api.example.com', changeOrigin: true, ws: true, }; app.use('/api', createProxyMiddleware(proxyOptions)); } } }
And install it like explained here: https://universal-vue.github.io/docs/plugins/#server
will checkout surely
I have the same problem and spent hours on it . Did you figure it out @SwapnilSoni1999 ? If not maybe @chymz can give us a help . All my axios requests don't reach my API server
same, so Im thinking to learn Nuxt and move my stuff in nuxt
By using
npm run ssr:serve
it is not working with the configuration provided invue.config.js
But when
npm run serve
is used it is working! Can anyone point me out where I'm wrong or its internal missing feature of uvue or something?In short:
devServer.proxy
is not working withnpm run ssr:serve
fromvue.config.js
npm run serve
is used! it is working. but problem is it is not ssrAdditional context