Closed MoritzStefaner closed 2 years ago
Right now it should work if you will use full path in links and Routes:
<a href="/app1/route1">Route1</a>
<a href="/app1/route2">Route2</a>
<Route path="/app1/*">
<Route path="/route1">This is route #1</Route>
<Route path="/route2">This is route #2</Route>
</Route>
Course you can use constant to define base:
<script>
import {BASE} from './my_constants.js'; // BASE='/app1';
</script>
<a href="{BASE}/route1">Route1</a>
<a href="{BASE}/route2">Route2</a>
<Route path="{BASE}/*">
<Route path="/route1">This is route #1</Route>
<Route path="/route2">This is route #2</Route>
</Route>
But I'll try to implement more explicit base defining. It will be something like this in near future:
<script>
import {router} from 'tinro';
router.setBase('app1');
</script>
<a href="/route1">Route1</a>
<a href="/route2">Route2</a>
<Route>
<Route path="/route1">This is route #1</Route>
<Route path="/route2">This is route #2</Route>
</Route>
Hi,
thanks for the response!
My goal was to keep the app itself totally agnostic of where it is deployed, and just operate on local paths completely. Do you think that is feasible or is there fundamental blocker? On 3. Sep 2021, 12:28 +0200, Alexey Schebelev @.***>, wrote:
Right now it should work if you will use full path in links and Routes: Route1 Route2
<Route path="/app1/*> <Route path="/route1>This is route #1 <Route path="/route2>This is route #2 Course you can use constant to define base:
<Route path="{BASE}/*> <Route path="/route1>This is route #1 <Route path="/route2>This is route #2 But I'll try to implement more explicit base defining. It will be something like this in near future:
MoritzStefaner commented 2 years ago
(I just noticed that enabling hash navigation using
router.mode.hash()
works for that case, so that's a partial win already :)
I added method router.base('/app1');
in 0.6.7 to set relative base path in the root component of your app.
It is impossible to determine that app is under subdirectory when using history API. All routers have config option to set base path.
Makes sense, and thanks for the quick help!
Hi,
thanks for this handy router.
I have a scenario where I want to deploy a svelte app in a subdirectory on a server, e.g. example.com/app1/ example.com/app2/.
How would I configure tinro to manage routes only under inside their own path? (e.g. /app1/route1). I tried relative paths, but this didn't seem to trigger the routes.
Thank you for any pointers!