Swagger UI没有在Amazon EC2实例上显示任何内容

发布于 2025-02-04 15:01:47 字数 488 浏览 6 评论 0原文

我已经使用Express Framework开发了Node.js应用程序,并使用“ Swagger-JSDOC”和“ Swagger-UI-Express”进行了记录。 Swagger UI正在加载我的“ Localhost:3000/V1/Docs”,并正常工作。

现在,我将其部署到Amazon EC2实例(Ubuntu,Linux),所有API都在击中和正常工作,但“ myamazonurl.com/v1/docs”正在重定向到Swagger UI,但没有显示任何东西。

我也配置了PM2和NGINX。

在控制台和网络中出现的错误是相同的,并且附加了错误。

首先点击URL:

第一个点击url”>

”重新加载页面“

运行Swagger UI需要其他配置或设置? 有什么问题?

我很感激...

I have developed Node.js App using Express framework and documented using "swagger-jsdoc" and "swagger-ui-express".
Swagger UI is loading on my "localhost:3000/v1/docs" and working properly.

Now, I deployed it to Amazon EC2 instance (Ubuntu, Linux), all API's are hitting and working properly but "myamazonurl.com/v1/docs" are redirecting to Swagger UI but not displaying anything.

I configured pm2 and nginx as well.

Errors coming in console and network are same and they are attached.

On first hit to the URL:

On first hit to the URL

On reloading the page:

On reloading the page

Is there any additional configuration or setup is required to run Swagger UI?
What is the issue?

I'll be thankful...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

新人笑 2025-02-11 15:01:47

只需移动app.use(helmet());插件上方的Swagger配置: -

const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('../swagger.json');
app.use('/v1/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(helmet());

即使尚未配置,它也强迫在HTTPS方案上找到资源。

来源: github

just move the swagger configuration above the app.use(helmet()); plugin :-

const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('../swagger.json');
app.use('/v1/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(helmet());

it is forcing to find resources on https scheme, even if it's not configured yet.

Source: Github

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文