no idea what i did
This commit is contained in:
Generated
+21
@@ -26,6 +26,7 @@
|
||||
"devDependencies": {
|
||||
"@types/bcryptjs": "^2.4.2",
|
||||
"@types/config": "^3.3.0",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/gravatar": "^1.8.3",
|
||||
"@types/jsonwebtoken": "^9.0.2",
|
||||
@@ -116,6 +117,16 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cors": {
|
||||
"version": "2.8.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
|
||||
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/express": {
|
||||
"version": "4.17.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
|
||||
@@ -552,6 +563,7 @@
|
||||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
@@ -2209,6 +2221,15 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/cors": {
|
||||
"version": "2.8.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
|
||||
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/express": {
|
||||
"version": "4.17.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"devDependencies": {
|
||||
"@types/bcryptjs": "^2.4.2",
|
||||
"@types/config": "^3.3.0",
|
||||
"@types/cors": "^2.8.17",
|
||||
"@types/express": "^4.17.17",
|
||||
"@types/gravatar": "^1.8.3",
|
||||
"@types/jsonwebtoken": "^9.0.2",
|
||||
|
||||
+6
-3
@@ -1,10 +1,13 @@
|
||||
import express from "express";
|
||||
|
||||
import connectDB from "./config/db";
|
||||
|
||||
import path from "path";
|
||||
import cors from "cors";
|
||||
|
||||
const app = express();
|
||||
|
||||
// add cors otherwise fronend cannot access backedn
|
||||
app.use(cors());
|
||||
|
||||
connectDB();
|
||||
|
||||
app.use(express.json());
|
||||
@@ -18,7 +21,7 @@ app.use("/api/posts", require("./routers/api/posts"));
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
console.log("in production");
|
||||
app.use(express.static("client/build"));
|
||||
app.get("*", (req, res) => [
|
||||
app.get("*", (_, res) => [
|
||||
res.sendFile(path.resolve(__dirname, "client", "build", "index.html")),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user