当页面尝试加载静态文件时,出现500错误。请记住,index.html确实加载了,但其他所有内容都没有加载。这是我得到的错误:
GET https://url/styles.27d4d011b38e19393988.css 500 (Internal Server Error)
注意:当我访问网络应用程序tru时,“正常”网址(http://url:3000)可以运行。
使用我的Nginx配置
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
server_name _;
root /var/www/html;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
}
我的server.js。 “ /”是我的角度应用程序的路径。
app.use(express.static(__dirname + '/dist'));
const isLoggedIn = (req, res, next) => {
if (!req.isAuthenticated()) {
res.redirect('/auth');
} else {
next();
}
};
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname));
// res.send('test');
});
app.get('/auth', passport.authenticate('oauth2-cognito'), (req, res) => {
res.redirect('/');
// res.send('test');
});
//add basic
const server = http.createServer(app);
// const serverhttps = https.createServer(app);
server.listen(port, () => {
console.log('Server running on: ' + port);
});
谢谢您的帮助。