Skip to content

Base URL support #101

@pi0

Description

@pi0

Describe the feature

Context: Asked by @schiller-manuel
How can I set a custom base path in srvx?

Sometimes it is useful to serve requests under a base URL to match the production environment.

While srvx (web Request) does not have a concept of base URL, we could emulate it by rewriting the request in a middleware (from /srvx/base-url similar to logger #94), and we can do path rewrite similar to h3.mount

We might need a fallback approach when the base is set to /base and users hit a path like /foo/bar, which needs to be redirected to /base/foo/bar. We need to do this redirect after next() if the response is 404 to allow the user-handler to optionally take over out-of-base situations.

We can also integrate middleware with CLI using an option like --base to add base url.

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions