Commit de385bad authored by Robert Knight's avatar Robert Knight Committed by Nick Stenning

Enable CORS support in package content server (#264)

Add CORS headers to assets served by the client's dev server, otherwise
the client's icon font will fail to load in many browsers.
parent d013842a
...@@ -21,6 +21,13 @@ var { version } = require('../../package.json'); ...@@ -21,6 +21,13 @@ var { version } = require('../../package.json');
function servePackage(port, hostname) { function servePackage(port, hostname) {
var app = express(); var app = express();
// Enable CORS for assets so that cross-origin font loading works.
app.use(function (req, res, next) {
res.append('Access-Control-Allow-Origin', '*');
res.append('Access-Control-Allow-Methods', 'GET');
next();
});
var serveBootScript = function (req, res) { var serveBootScript = function (req, res) {
var entryPath = require.resolve('../..'); var entryPath = require.resolve('../..');
var entryScript = readFileSync(entryPath).toString('utf-8'); var entryScript = readFileSync(entryPath).toString('utf-8');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment