preact-router
preact-router copied to clipboard
routing base path
Hi there, I would like to set a base path to preact-router
to serve a webapp from a "subfolder" of the root domain (ie: application from company.com/application
). I've noticed that I'm not the first one asking this question but searching through the issues I didn't understand if this feature has been developed or not and eventually how to use it.
Unfortunately when serving from from a company.com/application
type location, preact-router
redirects to the base company.com
domain, breaking many static assets links.
The only solution I have found has been to switch to hash routing, but I would prefer to keep the default routing behavior.
thanks
+1 for this issue, will try to do PR in my free time (tomorrow) if nobody does it
Hi any updates on this base path ?
@KowsalyaPK right now I use custom route function, you can do same stuff :)
@studentIvan Do you have a sample for the custom route function? Thank you.
@jiarongxu will this taken from context gist be enough for you? https://gist.github.com/studentIvan/a5f7b7dad184e0b0ef87a3d681209c04
@studentIvan How is this used with preact-router
? Could you provide some context to how and where the functions are called in your gist? Many thanks!
Ah neat solution @studentIvan - I hadn't thought of injecting into History, haha.
@jhdevuk I don't use the preact-router, only my local fork of it ( should be this probably https://github.com/studentIvan/preact-router/tree/feauture-extends-router-class ). The main differences are functions export possibility and extending. I set base-href in my appRegistry service first https://gist.github.com/studentIvan/e54fde89335fe0432d9665e04daa5b2b then I check it right in the route function.