Node.js 使用nodejs向heroku部署角度传感器
我在把项目交给heroku时遇到了一个问题 在这个网站上,我只在index.html文件中看到“hello”这个词,但它没有移动 我想我没有问题,但当我尝试连接时,我只看到hello和heroku日志中的tail,我收到了所有请求 现状:200 index.htmlNode.js 使用nodejs向heroku部署角度传感器,node.js,angular,heroku,Node.js,Angular,Heroku,我在把项目交给heroku时遇到了一个问题 在这个网站上,我只在index.html文件中看到“hello”这个词,但它没有移动 我想我没有问题,但当我尝试连接时,我只看到hello和heroku日志中的tail,我收到了所有请求 现状:200 index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Myapp</ti
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Myapp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<p>hello</p>
<app-root></app-root>
</body>
</html>
package.json
const express = require('express')
const path = require('path')
require('../mongoose/db/database')
const Menu = require('../mongoose/model/menu')
const app = express()
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname + '/dist/my-pizza-app')))
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
res.setHeader(
"Access-Control-Allow-Methods",
"GET, POST, PATCH, DELETE, OPTIONS"
);
next();
});
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname,'../', 'index.html'));
});
app.get('/meals', async (req,res) =>{
try{
const menu = await Menu.find({})
if(!menu){
return res.status(400).send()
}
res.status(201).send(menu)
console.log(menu)
} catch(e) {
res.status(500).send(e)
console.log(e)
}
})
module.exports = app
{
"name": "my-[enter image description here][1]app",
"version": "0.0.0",
"main": "src/server/app.js",
"scripts": {
"ng": "ng",
"start": "node src/server/app.js",
"build": "ng build",
"lint": "ng lint",
"e2e": "ng e2e",
"dev": "nodemon src/server/app.js"
},
"engines": {
"node": "~12.4.0",
"npm": "~6.9.0"
}
}
我到处搜索都找不到解决方案检查浏览器控制台,看是否有任何错误