-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with index html resources paths when using a complex path as route prefix #180
Comments
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests. |
Hello. I spent some time yesterday trying to solve the issue while retaining the behavior wanted by @DavidTanner. Sadly I'm needed elsewhere so I won't have much time to investigate further. |
Please can you fix that? Have the same problem: should be something like that... Sorry, but the code is pretty ambiguous anyway, I would generally go over it... |
How do I solve this problem, I still can't? |
I'm seeing the same problem. Specifying
and hitting localhost:5000/api/v1/help with browser yields a blank page. Inspecting the network activity, the initial GET on http://localhost:5000/api/v1/help works, but the ensuing resource GETs all receive 404s because their paths look like this
Interestingly, adding a trailing "/" (e.g. localhost:5000/api/v1/help/) fixes the problem. |
Correct me if I'm wrong, but it kind of seems like this is a bad setup of the server. Can someone please post a test example? I'm going to try recreating in the project as well. My first thought is that the fastify instance is already using that route prefix, and then you are specifying it again in the swagger config. Again, that is my first thought and I could totally be wrong. |
I figured out the issue, and will create a PR to fix. I need to add a new parameter to specify a prefix that only affects the index.html file. |
Good morning, everyone. Do you have an estimated time to approve this pull request? |
@ronielli new PR merged, just now waiting for the new release 🚀 |
FYI => #189 |
@rozzilla @DavidTanner Thank you so much! I just tested it, and everything is working perfectly. Great job! 😊 |
Resolved on our side as well, thank you! |
The previous version worked exactly as intended using relative paths. Now, I don’t quite understand how we’re supposed to proceed with this solution. If the application is run during development at, say, localhost:3000/help, and on the server at foo.com/myapi/v1/help, how can this combination be made to work? I don’t think it makes sense for the application to dictate where it is essentially 'parked' in terms of routing. Or am I missing something? I guess I am, could you fellows push me to a right direction? |
@MikaKarjunen I have that same issue with dev vs production. I have an environment variable that I key off of for production that sets the prefix when deploying. My first suggestion would be to set the indexPrefix to v1 using some env variable that is only set in the deployed environments. |
This is exactly what I was afraid of. We can make it work like this but it's not exactly what I would've liked to hear. |
You get my wheels spinning. We could propose an additional config option for the index to use relative paths. |
That would solve this nicely David. We'd much appreciate it and I suppose so would other people as well. Ultimately, the best outcome would be one where the installation process doesn’t need to inform the application about how it has been routed. |
Prerequisites
Fastify version
5.0.0
Plugin version
5.1.0
Node.js version
20.18
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
15.0.1
Description
It's appears #178 is causing an issue when using a complex path in
routePrefix
, ie:The resolved path looks like
/api/v1/api/v1/$docs/static
in that case.See linked repo for MRE.
Link to code that reproduces the bug
https://github.com/jpb06/fastify-swagger-ui-routeprefix-issue-repro
Expected Behavior
index resources to load properly.
The text was updated successfully, but these errors were encountered: