我已经建立了一个反应应用程序网页,我使用节点,表达和反应。我在带有 nginx 的 ec2 ubuntu 服务器中提供服务,我还安装了 ssl 并配置了 DNS,但是当我加载页面时,第一次没有问题,但是当重新加载时,我得到了这个 Server responded with 429 status code< /p>
页面本身非常简单,但仍然失败,我无法解决问题,我阅读了很多帖子和博客来修复它,但没有一个有效(这只发生在生产环境中,在开发环境中我得到运行我的节点应用程序时没有错误)。
有些人说你必须延迟加载图像,我做到了,我也尝试过超时加载组件,因此每 1.5 秒发出一次请求...
给我带来问题的主要文件是 manifest.json 和 favicon.ico,它们可以通过 url 访问,所以我不明白为什么({{3 }}).
路由什么都没有,只有控制台日志
require('dotenv').config();
const express = require("express");
const app = express();
const path = require("path");
const cors = require("cors");
const allowedOrigins = [`http://localhost:${process.env.PORT}`];
var corsOptions = {
origin: function (origin, callback) {
if (allowedOrigins.indexOf(origin) !== -1 || !origin) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
};
app.use(cors(corsOptions));
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(express.static(path.join(__dirname, "/public")));
app.use("/", require("./routes/routes"));
app.get("*", (_, res) => res.redirect("/"))
app.listen(process.env.PORT, function () {
console.log(`Listening on port ${process.env.PORT}`);
});
another 429 example,public 文件夹是 react 脚本 npm run build
返回的构建。
This is my folders structure,运行 npx create-react-app
时得到的结果没有什么特别之处。如您所见,有一个 favicon.ico
和 manifest.json
。
{
"short_name": "Proximedica Bajío",
"name": "Proximedica Bajío - Oxígeno Medicinal",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
这就是全部,如果您需要我提供一些其他文件,那将是一种乐趣。 谢谢!