route.yml
With the rollout of URL unification, this guide is currently considered outdated.
This file is source of truth that is used by dev proxy to determine which service to forward the request to based on URL. It consist of collection of rules to follow, where the first entry takes highest precedence. After router get matching handler, it will stop searching.
Rule pattern
Each rule consist of pattern property to specify a path to match. You can then use app to tell the proxy how to find the package.
routes:
desktop:
- pattern: /sample
app: websmp-desktop
How it works
The way the router works is by matching exact patch (excluding route prefix), so in the first example: /sample will match but /sample/x won't. If you want slightly more powerful route you can use wildcard * token:
routes:
desktop:
- pattern: /sample*
app: websmp-desktop
This will match any routes prefixed by /sample. Another thing you can do using this method is to match partial segment. For example you have routes like /activities/[country]/detail/[nameId] and you want to match it in the route level, you can create definition like this:
routes:
desktop:
- pattern: /activities/*/detail/*
app: webxpe-desktop
Note that the router doesn't support dynamic route with named params like /activities/[country]/detail/[nameId] so you still need to add the route matching logic in your express server.
Because we rely on the order of the route definition, you can combine your rule with route overrides. To do this simply add webmono rule above your routes. This is especially useful if you're planning to migrate your route from nodejs-web to TVLK5. For example if you want /activities/[country]/detail/[nameId] to be handled by nodejs-web but the rest of routes in TVLK5 you can do this:
routes:
desktop:
- pattern: /activities/*/detail/*
app: webmono
- pattern: /activities*
app: webxpe-desktop
Custom package name
If you use a different package for your route, you need to specify package name (not directory name) using packageName. Both port will be handled by that package.
apps:
default:
packageName: '@traveloka/webstd'
Note: The rules are separated by interface (desktop & mobile). Make sure you modify the correct one