Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

How to config proxyTable for CORS #387

Closed
houchr opened this issue Sep 8, 2017 · 2 comments
Closed

How to config proxyTable for CORS #387

houchr opened this issue Sep 8, 2017 · 2 comments

Comments

@houchr
Copy link

houchr commented Sep 8, 2017

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.

@houchr
Copy link
Author

houchr commented Sep 8, 2017

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.

@houchr
Copy link
Author

houchr commented Sep 12, 2017

insert webPreferences: {webSecurity: false} at new BrowserWindow()

like this:

mainWindow = new BrowserWindow({
    height: 563,
    useContentSize: true,
    width: 1000,
    frame: false,
    webPreferences: {webSecurity: false}
  })

@houchr houchr closed this as completed Sep 12, 2017
adrinicomartin added a commit to adrinicomartin/electron-vue that referenced this issue Mar 2, 2018
Documentation change after SimulatedGREG#387.

This can save a lot of time for newer people in electron and vuejs.
adrinicomartin added a commit to adrinicomartin/electron-vue that referenced this issue Mar 2, 2018
Documentation change after SimulatedGREG#387.

This can save a lot of time for newer people in electron and vuejs.
bryan-justin added a commit to bryan-justin/vue-template-electron that referenced this issue May 1, 2022
Documentation change after SimulatedGREG/electron-vue#387.

This can save a lot of time for newer people in electron and vuejs.
Artem0328 added a commit to Artem0328/electron-vue that referenced this issue Sep 15, 2023
Documentation change after SimulatedGREG/electron-vue#387.

This can save a lot of time for newer people in electron and vuejs.
JeffUlan added a commit to JeffUlan/electron-vue that referenced this issue Sep 17, 2023
Documentation change after SimulatedGREG/electron-vue#387.

This can save a lot of time for newer people in electron and vuejs.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant