diff --git a/bin/dev-server.js b/bin/dev-server.js index 3a67dbec14..b17ee562af 100755 --- a/bin/dev-server.js +++ b/bin/dev-server.js @@ -2,8 +2,9 @@ 'use strict'; +const http = require('http'); var watch = require('watch-glob'); -var http_server = require('http-server'); +const serveHandler = require('serve-handler'); var debounce = require('lodash.debounce'); var browserify = require('browserify'); var fs = require('fs'); @@ -92,7 +93,15 @@ var readyCallback; function startServers(callback) { readyCallback = callback; - http_server.createServer().listen(HTTP_PORT, function () { + const server = http.createServer((req, res) => { + // Add cross-origin isolation headers to allow for more precise performance measurements. + // See: https://developer.mozilla.org/en-US/docs/Web/API/Performance/now#security_requirements + res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); + res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); + + return serveHandler(req, res, { trailingSlash:true }); + }); + server.listen(HTTP_PORT, () => { var testRoot = 'http://127.0.0.1:' + HTTP_PORT; const query = new URLSearchParams(queryParams); console.log(`Integration tests: ${testRoot}/tests/integration/?${query}`); diff --git a/package.json b/package.json index c0d38acefb..959c9d9659 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "express-pouchdb": "4.2.0", "find-requires": "1.0.0", "glob": "7.1.5", - "http-server": "0.12.3", "istanbul": "0.4.5", "istanbul-coveralls": "1.0.3", "less": "3.9.0", @@ -99,6 +98,7 @@ "rollup-plugin-node-resolve": "4.2.4", "rollup-plugin-replace": "1.2.1", "seedrandom": "3.0.5", + "serve-handler": "6.1.5", "source-map": "0.7.4", "stacktrace-parser": "0.1.10", "stream-to-promise": "1.1.1",