#CORS 'null' origin Issue Preventing App from Working in SPA Mode

4 messages · Page 1 of 1 (latest)

shut oxide
#

Hello everyone, I'm reaching out to seek some assistance with a CORS issue that's causing problems with our web application. Here's a brief overview of the problem:

Issue Description:
We have developed a web app that needs to run in SPA mode with SSR set to false. It works on live server. However, when we attempt to open the app (/dist/index.html) using the file protocol (we need it so it works on the client device), we encounter the following CORS errors:

Access to script at 'file:///C:/[path]/app/dist/_nuxt/entry.0617e852.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Failed to load resource: net::ERR_FAILED

Additional Information:
We are not doing any API calls, we just generate a basic Nuxt app.
We have already tried updating the headers with the Nuxt Security module, like so:

    security: {
        corsHandler: {
            origin: 'file://',
            methods: '*',
            allowHeaders: '*',
            exposeHeaders: '*',
            credentials: true
        }
    },

If you need more details about our configuration or code, please let us know, and we'll provide them promptly.

Thank you in advance for your assistance!

dim ravine
#

@shut oxide ....does it mean you can't serve it on local server ?

http://localhost

shut oxide
#

@dim ravine Yes, on local server works as expected. The problem is when we run generate and we open the index.html, it doesn't display anything and the console shows the errors mentioned above.

dim ravine
#

@shut oxide did you try

http-server -o

within the folder which contains html