Closed TylorS closed 8 months ago
Hey, yes, I can reproduce. I was solving a similar issue already but using HttpServer.router.mount
(my use case is that I want to mount the swagger router without the whole effect-http machinery). With HttpServer.router.mount
, the prefix
is propagated within the HttpServer.router.RouteContext
which the swagger router uses to generate the correct path in the index.html
. The HttpServer.router.mountApp
doesn't seem to do so.
Thanks for the quick response @sukovanej, I could definitely see being able to split it out into it's own handler so you can compose things as you see fit.
Regarding mount vs mountApp, it kinda sounds like a bug if mountApp doesn't propagate all relevant route information, no?
I started a thread in the effect discord. Let's confirm with Tim whether this is something to be fixed in the @effect/platform. If yes, let's do the adjustment in the @effect/platform and the fix here will be to update. If no, maybe there will be a way to check the mount path or something to make it work with mountApp
. Otherwise, we'll need provide a way to configure the base path as you proposed.
Hey, I resolved it by introspecting the originalUrl
on the request and calculating the prefix based on that. Please try to update to the latest version, it should start working with both mount
and mountApp
now.
@sukovanej I can confirm it works great! Thank you for your help 🙏
It seems like the the hard-coding of
/docs
as the base path for the swagger router is preventing mounting an application usingRouter.mountApp('/api', server)
from platform. To be more specific, the docs.html
loads fine, but all of the assets fail to load at/docs/{filename}
when I'd really want for them to load from/api/docs/{filename}
I'm attempting to create a full-stack implementation of the "realworld" application, and the specification requires the API portion to run at
/api/*
, while the client rendering happens at/*
.I think just adding some kind of base path configuration would be totally sufficient, or maybe there's a way to adjust it with
SwaggerFiles
already?