I use :
// dev-runner.js:startRenderer ()
const server = new WebpackDevServer(
compiler,
{
contentBase: path.join(__dirname, '../'),
quiet: true,
setup (app, ctx) {
app.use(hotMiddleware)
ctx.middleware.waitUntilValid(() => {
resolve()
})
},
proxy: {
'*' : {
changeOrigin: true,
target: 'http://127.0.0.1:8000'
}
}
}
)
error log:
XMLHttpRequest cannot load http://127.0.0.1:8000/api/v2/users. No 'Access-Control-Allow-Origin'
header is present on the requested resource.
Origin 'http://localhost:9080' is therefore not allowed access.
How to config proxyTable for CORS ?
thanks.
axios call:
this.$http.get('http://127.0.0.1:8000/api/v2/users', qs.stringify({
headers: {
'Access-Control-Allow-Origin': '*'
}
})).then(response => {
// success callback
console.log(response)
}, response => {
// error callback
console.log(response)
})
and servcie already config.
insert webPreferences: {webSecurity: false} at new BrowserWindow()
like this:
mainWindow = new BrowserWindow({
height: 563,
useContentSize: true,
width: 1000,
frame: false,
webPreferences: {webSecurity: false}
})
Most helpful comment
insert webPreferences: {webSecurity: false} at new BrowserWindow()
like this: