choojs / choo

:steam_locomotive::train: - sturdy 4kb frontend framework

Home Page:https://choo.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running Router On a Specific Path with Hash Routing

AcidLeroy opened this issue · comments

This is more of a help wanted issue. The problem that I am having is that I am attempting to put a choo.js app that is not on the root path of site, i.e. mysite.com/#userid. Instead, I am attempting to run the site on mysite.com/biz/baz/myapp/#userid. What do I need to do, assuming I don't have server control, to get my hash routes to work on an arbitrary root location on the path?

I've tried the following and this didn't work for me:

const prefix = '/biz/baz/myapp'
app.route(prefix+'/', welcome)
app.route(prefix+'#:userid', user)

Is there a trick that I need to do in order to stick my choo app on a subregion of mysite?

Thanks!

Check this issue for more information: #666

I'm having the same problem. I'd love it if my choo routes were interpreted to be relative to the directory from which the app is served (as opposed to the domain root), but I can't figure out how to do this.

@AcidLeroy If you are comfortable putting the path prefix you deploy to in your code, I was able to get your scenario to work like so:

let app = choo({ hash: true });
app.route('/some/path', mainView);
app.route('/some/path/users/:user_id', userView);

But I'd love it if someone could help me get this to work without including the deployment path in the source of the app. I.e. using paths relative to the deployment path.