Jelajahi Sumber

跨域不使用*

yangc 7 tahun lalu
induk
melakukan
5cc70c7c92
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      server.js

+ 1 - 1
server.js

@@ -17,7 +17,7 @@ const proxyTable = config.proxyTable
 if (proxyTable) {
 if (proxyTable) {
   // 本地代理支持localhost、127.0.0.1等不同地址跨域
   // 本地代理支持localhost、127.0.0.1等不同地址跨域
   app.use((req, res, next) => {
   app.use((req, res, next) => {
-    res.header('Access-Control-Allow-Origin', req.headers.referer)
+    res.header('Access-Control-Allow-Origin', `${req.protocol}://${req.headers.host}`)
     res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
     res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
     res.header('Access-Control-Allow-Headers', 'Content-Type')
     res.header('Access-Control-Allow-Headers', 'Content-Type')
     res.header('Access-Control-Allow-Credentials', 'true')
     res.header('Access-Control-Allow-Credentials', 'true')