schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs and SSR.
https://jasprpad.schultek.de
MIT License
1k stars 59 forks source link

fix: jaspr_router not honoring base href #182

Closed walsha2 closed 3 months ago

walsha2 commented 4 months ago

Description

Having an issue with jaspr_router when deploying an jaspr application (client only template) to a location that is not the root origin. For example, when deploying to Github Pages, the URL looks like this:

https://username.github.io/repo/

In turn, we would need to update the HTML base href so that the application knows where to look for assets:

<base href="/repo/">

This works for fine assets, however jaspr_router does not seem to have an option to honor the defined base href in head.

Steps To Reproduce

Here is a live example of this very issue (code is still a work in progress):

https://tazatechnology.github.io/jaspr_tailwind_ui/

<base href="/jaspr_tailwind_ui/">

The application will not route properly to the home route of /:

Page Not Found
Exception: Match error found during build phase Exception: no routes for location: /jaspr_tailwind_ui/

https://github.com/tazatechnology/jaspr_tailwind_ui/blob/eac200b1381ff21748fb1258dca1c468982aa7fc/example/web/main.dart#L30-L49

walsha2 commented 4 months ago

@schultek similar to https://github.com/schultek/jaspr/issues/180#issuecomment-1987414543, this is also due to the app being a client side only web app?

I see options for base and handling of base href in Document of the server stub. I wonder if the logic in here is what trickles down to the router and in turn it is honored? I dont see any similar base href handling in the static client only app template.