-
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
Can't specify host to work correctly with nginx generated subroutes #176
Comments
Transfering to fastify-swagger-ui, because the problem seems to be there. Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that. |
@mcollina |
I had the same issue, and found a fix. I assumed the I tested it with your example repo @Danko14 and was able to get it to work correctly. I had to also change the port in the Dockerfile, but that shouldn't affect the validity of the change. |
@DavidTanner Can you send a PR to update the docs for that? |
I would, but I don't think that is the right way. I'm trying out some other changes |
Genius. Just like I imagined it |
Prerequisites
Last working version
7.4.0
Stopped working in version
9.0.0
Node.js version
22.9.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.0
💥 Regression Report
I'm using fastify with docker and nginx API gateway, so I always need to specify service api url in my swagger configuration, so that it is routed correctly.
after update, I couldn't find "host" parameter I used before, and while it all works fine locally, it crashes on server, being unable to fetch lib files, such as swagger-ui-bundle.js.
e.g. request goes to https://mydomain/docs/swagger-ui-bundle.js while the correct path is https://mydomain/v1/mock-server/docs/swagger-ui-bundle.js and getting either html or 404 response
routePrefix and servers parameters couldn't help me here
maybe I'm missing an obvious solution, but I couldn't find any in documentation or existing tickets.
sources mismatch:
thanks in advance!
Steps to Reproduce
clone repo
https://github.com/Danko14/fastify-swagger
follow readme steps (create .env & run docker-compose)
you'll get nginx running on 80 and mock server running on 8080 and available on http://localhost/mock-server/
query http://localhost/mock-server/ping to get { msg: 'ok' }
query http://localhost:8080/docs to see swagger docs
query http://localhost/mock-server/docs to see where the problem is
swagger config:
fastify.register( fastifySwagger, { openapi: { info: { title: 'Mock server', description: 'API documentation', version, }, servers: [ { url:
https://${process.env.SERVER_API_URL}, description: 'HTTPS' }, { url:
http://${process.env.HTTP_HOST}:${process.env.HTTP_PORT}, description: 'HTTP' }, ], components: { securitySchemes: { actorId: { type: 'apiKey', in: 'header', name: 'x-actor-id', }, actorType: { type: 'apiKey', in: 'header', name: 'x-actor-type', }, }, }, security: [ { ApiKeyAuth: [] }, { ActorTypeAuth: [] }, ], }, }, ) fastify.register(swaggerUi, { routePrefix: '/docs', uiConfig: { docExpansion: 'list', deepLinking: false, }, staticCSP: false, transformSpecification: (swaggerObject, request, reply) => swaggerObject, transformSpecificationClone: true, })
nginx config:
Expected Behavior
No response
The text was updated successfully, but these errors were encountered: