htmlvisual-studio-codeliveserverstatic-pages

VS Code Live Server: "Cannot GET <page>" error message


I'm currently developing a simple static web page with only HTML. I'm using <a> tags with href to links to different pages and the VS code live server used to work. When I inserted a link such as page1.html it would send the browser to this page. But I prefer to have just the page without the .html.

When I remove the .html from the link the live server gives an error:

Cannot GET /page1

But when I deploy my site on Netlify it does, however, find the page, but this breaks the development process for me.

How can I fix the live server so it also gets sent to the correct page?


Solution

  • This is a common server behaviour. The server tries to find a file or folder name page1 but doesn't find it. Nothing wrong with live server. I guess Netlify is the one doing extra magic.

    However if you want to remove the .html in page1 you could create a folder name page1 and put inside a index.html with the content. This way the server will find the folder named page1 and return the index.html. This will also work with live server and any standard server.

    This is how your folder structure could look like: enter image description here