Make WDS CORS settings correct

This commit is contained in:
Marshall Quander 2018-08-02 17:59:37 -07:00
Родитель 2703b6d7d0
Коммит c98d15a920
3 изменённых файлов: 14 добавлений и 1 удалений

10
package-lock.json сгенерированный
Просмотреть файл

@ -3206,6 +3206,16 @@
"resolved": "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cors": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz",
"integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=",
"dev": true,
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"cosmiconfig": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.5.tgz",

Просмотреть файл

@ -69,6 +69,7 @@
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"copy-webpack-plugin": "^4.5.1",
"cors": "^2.8.4",
"css-loader": "^1.0.0",
"dotenv": "^5.0.1",
"eslint": "^5.2.0",

Просмотреть файл

@ -7,6 +7,7 @@ const fs = require("fs");
const path = require("path");
const selfsigned = require("selfsigned");
const webpack = require("webpack");
const cors = require("cors");
const HTMLWebpackPlugin = require("html-webpack-plugin");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
@ -76,8 +77,9 @@ module.exports = (env, argv) => ({
host: "0.0.0.0",
useLocalIp: true,
allowedHosts: ["hubs.local"],
headers: { "Access-Control-Allow-Origin": "hubs.local" },
before: function(app) {
// be flexible with people accessing via a local reticulum on another port
app.use(cors({ origin: /hubs\.local(:\d*)?$/ }));
// networked-aframe makes HEAD requests to the server for time syncing. Respond with an empty body.
app.head("*", function(req, res, next) {
if (req.method === "HEAD") {