Skip to content
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

Failing to load swagger.json in production #28

Open
xn3cr0nx opened this issue Feb 8, 2020 · 3 comments
Open

Failing to load swagger.json in production #28

xn3cr0nx opened this issue Feb 8, 2020 · 3 comments

Comments

@xn3cr0nx
Copy link

xn3cr0nx commented Feb 8, 2020

Hi, I'm running a restify server with this package that is working correctly locally, but I have a problem in production where it always tries to fetch the swagger.json file from localhost.

This is my configuration. I'm running it based on environment and "docs_host" config var is actually the production url.


restifySwaggerJsdoc.createSwaggerPage({
  title: `${name} API documentation`,
  version: version,
  server: app,
  path: "/docs",
  host: process.env.NODE_ENV == "development" ? `${host}:${port}` : config.get("docs_host"),
  routePrefix: "/api",
  apis: [process.env.NODE_ENV == "development" ? "./app/**/*.ts" : "./app/**/*.js", "./app/**/*.yml"],
});

As you can see from the screen it tries to fetch from localhost while the host is set to remote url. I tried to update path with the docs_host too, but I got an error because it requires the field to start with "/".

image

Replacing localhost and port with the docs_host in explore input field it actually loads correctly the UI. Is there something wrong in my configuration?

P.S: side question, is openapi option available as in swagger-json lib? I see it actually defaults to swagger v2.

@RajatYadav3
Copy link

Hi @xn3cr0nx
I am facing the same issue in production. Docs are pulling up on localhost but not in production i.e. on https.
My production URL is like https://abc.com/test/
but while calling https://abc.com/test/docs it automatically redirects to https://abc.com/docs/index.html

createSwaggerPage({ title: "API documentation", version: "1.0.0", server: server, schemes: ["https"], path: "/docs", apis: ["./src/routes/*Route.ts"] });

Note: Replacing the URL to https in explore and using the url like https://abc.com/test/docs/swagger.json in explore input field. It works.

@RajatYadav3
Copy link

RajatYadav3 commented Jan 10, 2022

@RemyJeancolas please fix

@RemyJeancolas
Copy link
Owner

Hi @RajatYadav3.

I'm not sure I understand your use case, can you give more details?
If you think you have a solution for this problem, don't hesitate to propose a PR, I will be happy to review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants