Dogstudio / highway

Highway - A Modern Javascript Transitions Manager

Home Page:https://highway.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add options for error pages

TristanPct opened this issue Β· comments

Hello, it's me again πŸ˜„

For the moment when Highway encounter an error page (404, 500...) it sends the NAVIGATE_ERROR event but doesn't try to load the page (event if this page have a router-view).

Is it planned to add an option to load error pages likes other pages ?

For the moment an alternative is to tell the error page to have an HTTP 200 code rather than error code if X-Requested-With: Highway header is present.

Hi @TristanPct ,

We are currently working on the v2.0 of Highway...

We have add a new method called location to Highway.Core that'll give you the ability to redirect to a page like you would do with window.location but using Highway.

So I would say that since the NAVIGATE_ERROR event gives you acces to the HTTP/Request status, you'll be able to know the status code and use this method to redirect to the right error page using this new method. What do you think ?

Cheers,
Anthodpnt

πŸ‘ This method could be usefull, for this case or others.

But with this technique the browser load the error page twice (for the NAVIGATE_ERROR and for the location method).

Perhaps a method or parameter in the NAVIGATE_ERROR event telling continue anyway (like event.continueRouting() for example) could avoid this double page load.

@TristanPct I understand what you mean and we'll look into a cleaner solution as soon as possible.

@TristanPct We juste released the v2.0.0 of Highway that will fix your issue. Since we cannot predict that there will be an error or that an error page is provided we have to hard reload the page as soon as the response.status of the HTTPRequest is outside the 200-299 range.

Best regards,
Anthodpnt