P
P
pavtaras2015-11-20 16:42:11
JavaScript
pavtaras, 2015-11-20 16:42:11

What to do after reloading the js page if the History API is used?

The bottom line is this: the History API is used on the main page of the site. If the url changes from example.com to example.com/contacts, then when we reload the page, we obviously get a 404 error, because the server is trying to return the page that is located at this url, which is not there, because we have a Single Page Application.
Is there any way out other than the obvious - to generate a page on the server?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kravchenko, 2015-11-20
@mydearfriend

redirect the request using the web server

V
v- death, 2015-11-20
@vGrabko99

redirect all requests to index.html (by means of a web server), and in index.html just parse the url from the browser (location.pathname) and load the piece that matches the url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question