skip to Main Content

my project is working fine when I am opening it through vs code live server , it has API in it enter image description here

but when I am opening it directly through my folder its doesn’t work , I don’t understand what’s the problem . Also the URL changed , Please someone help me , what’s the problem ?? enter image description here

3

Answers


  1. The difference is that in the first case, the page is being served by a web server, whereas in the second, you’re just loading the file off of the disk, directly into the browser.

    In the case of a static HTML page, this doesn’t matter, because there isn’t any processing that has to be done, but when you start using web services that get called by Javascript, it does matter, because those web services are programs that have to be run on the server side, and that server isn’t available if you’re just loading the files off of the disk.

    Login or Signup to reply.
  2. It depends about the structure of your HTML file, but if it calls a function it will be have to be computed somewhere and you need to validate that an engine actually runs it.

    I am assuming you are using a standard procedure, make sure your executor is on.

    Login or Signup to reply.
  3. When you open an HTML file directly from your disk, some JavaScript functions might be restricted due to the browser’s security policies. This happens because loading files locally is seen as a security risk. Using Live Server bypasses these restrictions by running a local server, creating a more real server-like environment, and allowing your JavaScript code to work smoothly.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search