작성
·
12
0
npm run dev로 서버는 성공적으로 올라갔는데 localhost:3000 접속 시 연결이 거부되었다고 뜹니다.
이것저것 많이 찾아보긴 했는데 해결이 안되네요 ㅠㅠ
windows, 크롬에서 실행했습니다. 해결 방법을 알 수 있을까요?
// index.js
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const app = express();
const config = require("./server/config/keys");
// const mongoose = require("mongoose");
// mongoose.connect(config.mongoURI, { useNewUrlParser: true, useUnifiedTopology: true })
// .then(() => console.log('MongoDB Connected...'))
// .catch(err => console.log(err));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/api/dialogflow', require('./server/routes/dialogflow'));
// Serve static assets if in production
if (process.env.NODE_ENV === "production") {
// Set static folder
app.use(express.static("client/build"));
// index.html for all page routes
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});
}
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(`Server Running at ${port}`)
});
//package.json
{
"name": "chatbot-app",
"version": "1.0.0",
"description": "chatbot-app",
"main": "index.js",
"engines": {
"node": "18.20.5",
"npm": "10.9.0"
},
"scripts": {
"start": "node index.js",
"backend": "nodemon index.js",
"frontend": "npm run front --prefix client",
"dev": "concurrently \"npm run backend\" \"npm run start --prefix client\""
},
"author": "Jaewon Ahn",
"license": "ISC",
"dependencies": {
"actions-on-google": "^3.0.0",
"body-parser": "^1.20.3",
"dialogflow": "^1.2.0",
"dialogflow-fulfillment": "^0.6.1",
"dotenv": "^16.4.5",
"express": "^4.21.1",
"mongoose": "^8.8.1",
"node": "^18.20.5",
"punycode": "^2.3.1"
},
"devDependencies": {
"@ant-design/icons": "^5.5.1",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"concurrently": "^9.1.0",
"nodemon": "^3.1.7"
}
}
client쪽
//package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"antd": "^4.24.16",
"axios": "^1.7.7",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.28.0",
"react-scripts": "5.0.1",
"redux": "^5.0.1",
"redux-promise": "^0.6.0",
"redux-thunk": "^3.1.0",
"uuid": "^11.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"http-proxy-middleware": "^3.0.3"
}
}
답변