Skip to content

/swagger/json returning 404 if Swagger is used in conjunction with a prefix set in Elysia #183

Closed
@sludgepudge

Description

@sludgepudge

When setting a prefix in Elysia and simultaneously using Swagger, it fails to correctly load /swagger/json.

To reproduce:

new Elysia({ prefix: '/v1' })
	.use(swagger())
	.use(logixlysia()) // logger used to highlight responses on console
	.get('/', () => 'Hello!')
	.listen(3000);

Visit the server in a browser http://localhost:3000/v1/swagger and you'll be presented with the UI theme of Scalar, but no content.

Adding a logger reveals that /v1/swagger gets hit and returns a 200 status, immediately followed by /swagger/json (note the lack of prefix) getting hit with a 404 status.

It seems this has been attempted to be fixed before #16 but has remained an ongoing issue since at least October 2024.

image image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions