Use this file to discover all available pages before exploring further.
compartment.routes.yml is an optional file you place at your repository root alongside compartment.yml. When present, it defines how incoming browser requests are routed across your services — for example, forwarding /api/* from your web frontend to a dedicated API service. If you only have a single service and no cross-service routing needs, you can omit this file entirely.
Use the methods field to restrict a rule to specific HTTP verbs. Supported methods are DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. Method filtering runs before path rewriting, so a request that does not match the method list is not affected by the rule.
routes: - on: web path: /api/* to: api methods: - GET - POST stripPrefix: /api
Each rule may include at most one transform field. Combining multiple transform fields on the same rule is not allowed.
Transform
Description
rewrite
Replaces the entire upstream path with the given concrete path.
stripPrefix
Removes the matched prefix from the path before forwarding.
replacePrefix
Swaps the matched prefix for a different prefix before forwarding.
When no transform is set, the original request path is forwarded to the target service unchanged. Query strings are preserved in all cases.
Transform paths must be concrete upstream paths. They must not end with /*. stripPrefix and replacePrefix require a prefix path (one ending with /*) as the route path. stripPrefix must exactly match the route path prefix.
Rules are evaluated in the order they appear in the file. The first rule that matches the incoming request wins — no subsequent rules are evaluated. Keep more specific rules above more general ones.
Exact paths match only that exact path.
Prefix paths (/*) match the prefix itself or any deeper path.
Method filtering runs before path rewriting.
Query strings are preserved when a rule rewrites the path.
compartment.routes.yml is a companion to compartment.yml — it reads service names from compartment.yml but controls routing concerns that compartment.yml deliberately does not own. Changes to either file take effect on the next deployment.