Przeglądaj źródła

Set hostname to kitchn server

Tati 7 lat temu
rodzic
commit
86e6dc1a22
1 zmienionych plików z 6 dodań i 1 usunięć
  1. 6 1
      ktchn/src/server.ts

+ 6 - 1
ktchn/src/server.ts

@@ -56,6 +56,11 @@ class App {
     this.app.use(bodyParser.urlencoded({ extended: false }));
     this.app.use(cookieParser());
     this.app.use(express.static(path.join(__dirname, "public")));
+    this.app.use((req, res, next)=> {
+      res.header("Access-Control-Allow-Origin", "*");
+      res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
+      next();
+    })
   }
 
   private connectDB(): Promise<MongoClient.Db> {
@@ -66,7 +71,7 @@ class App {
     this.connectDB().then(db => {
       this.routes(db);
       const port = this.app.get("port");
-      this.app.listen(port, () => {
+      this.app.listen(port, '0.0.0.0', () => {
         console.log(
           ("App is runnnning at http://localhost:%d in %s mode"),
           port,