From b6c45b53a48679545fafb47657bbee188af9e263 Mon Sep 17 00:00:00 2001 From: qiaodong Date: Sun, 29 Nov 2020 23:57:04 +0800 Subject: [PATCH] fix Express CROS block 127.0.0.1 --- 7-bank-project/api/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/7-bank-project/api/server.js b/7-bank-project/api/server.js index 7a369fb6..af114ea1 100644 --- a/7-bank-project/api/server.js +++ b/7-bank-project/api/server.js @@ -27,7 +27,7 @@ const db = { const app = express(); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); -app.use(cors({ origin: /http:\/\/localhost/ })); +app.use(cors({ origin: /http:\/\/(127(\.\d){3}|localhost)/})); app.options('*', cors()); // ***************************************************************************