Skip to content

Support for Relative Path in Hono Client #4186

@mosleim

Description

@mosleim

What is the feature you are proposing?

Currently, the Hono client always returns an absolute URL object when using the $url() method. This creates issues when working with relative paths, especially in environments where the base URL might change or when building URLs that need to remain relative.

Current Behavior

const client = hc('/api');
const url = client.users.$url(); // Returns URL object with absolute path

The code in client.js always returns new URL(result), which converts relative paths to absolute URLs based on the current origin. and throwing an error.

Expected Behavior

Provide an option to return relative URLs as strings instead of URL objects.

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