Browse Source

change access-control-origin

maguohua 8 năm trước cách đây
mục cha
commit
9f345a38c6
2 tập tin đã thay đổi với 1 bổ sung2 xóa
  1. 0 1
      README.md
  2. 1 1
      app.js

+ 0 - 1
README.md

@@ -244,7 +244,6 @@ npm run dev (需先开启mongodb)
 ├── README.md                  
 .
 
-
 47 directories, 197 files
 
 ```

+ 1 - 1
app.js

@@ -14,7 +14,7 @@ import Statistic from './middlewares/statistic'
 const app = express();
 
 app.all('*', (req, res, next) => {
-	res.header("Access-Control-Allow-Origin", req.headers.origin);
+	res.header("Access-Control-Allow-Origin", req.headers.origin || '*');
 	res.header("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With");
 	res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
   	res.header("Access-Control-Allow-Credentials", true); //可以带cookies