Vscode-live-server: It says "CORS Enabled" but can't access files from external domains.

Created on 7 Dec 2018  路  3Comments  路  Source: ritwickdey/vscode-live-server

I really don't know if this is a bug report or a feature request because I don't know what you mean by "CORS Enabled" in the description and I didn't find any reference in the docs. Anyway, it would be nice to have Allow Origin headers automatically added to pages served with Live Server. I know that you can add the flags or install an extension to Chrome but that makes navigation while developing insecure. "Allow Origin" should be added only for the pages you are developing.

Chrome
Live Server 5.3.1

Most helpful comment

I found a way to fix this problem so far (even though it looks like so bad), adding below config to your settings.json .

{
    "liveServer.settings.proxy": {
        "enable": true,
        "baseUri": "/api", 
        "proxyUri": "http://127.0.0.1:8080/"
    }
}

All 3 comments

I agree. The use case with Live Server does not warrant Same Origin Policy. CORS should be enabled.

I found a way to fix this problem so far (even though it looks like so bad), adding below config to your settings.json .

{
    "liveServer.settings.proxy": {
        "enable": true,
        "baseUri": "/api", 
        "proxyUri": "http://127.0.0.1:8080/"
    }
}

Hey I have the same issue when using d3.js. How to fix this issue?

d3.html('http://enable-cors.org')
  .get((err, data) => {
    console.log(data)
  })

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhiinos111abhi picture abhiinos111abhi  路  5Comments

manavm1990 picture manavm1990  路  5Comments

tehsy97 picture tehsy97  路  6Comments

js76155 picture js76155  路  4Comments

Er-rchydy picture Er-rchydy  路  3Comments