Error when trying to run shopping cart app on a chrome tab [Building a Mobile App Lesson]

I downloaded the files for this lesson at the start to try and follow along myself on vscode but it seems like chrome wont let me run the html file.
On lesson 4 where we’re asked to implement the push function it seems like my button presses arent going through. And on the startup of the app on chrome, it shows the following error:

Access to script at ‘file:///C:/Users/…/Shopping-List-App/index.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.

along with:

GET file:///C:/Users/…/Shopping-List-App/index.js net::ERR_FAILED

What might be the issue here?

Hey!
Can you list the exact process you went through to try to run this code in VS Code?
It looks like you have an invalid path - that the app can’t actually find a file in the place you are telling it to look.

Hi, I realized that I needed to run the html file in a live server instead of just opening the html file on my browser. Thanks for the reply.

1 Like