Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit a6f5832

Browse files
committed
replace spa-http-server with js file to get around looping redirects
1 parent 50520d7 commit a6f5832

File tree

3 files changed

+268
-87
lines changed

3 files changed

+268
-87
lines changed

cypress-spa-server.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const express = require('express');
2+
const path = require('path');
3+
4+
const port = 8080;
5+
const app = express();
6+
7+
// serve static assets normally
8+
app.use(express.static(path.resolve(__dirname, 'dist')));
9+
10+
// block known api route causing looping redirect
11+
app.get('/rpi/*', (request, response) => {
12+
response.send('fin.');
13+
});
14+
15+
// handle every other route with index.html
16+
app.get('*', (request, response) => {
17+
response.sendFile(path.resolve(__dirname, 'dist/index.html'));
18+
});
19+
20+
app.listen(port);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"test": "yarn unit && yarn e2e-with-mocks",
1717
"lint": "eslint --ext .js,.vue src test/unit/specs",
1818
"mock-server": "node ./json-server/server.js",
19-
"cypress": "yarn build && concurrently --kill-others --success first \"http-server dist/ --push-state > /dev/null\" \"cypress run --browser chrome\"",
19+
"cypress": "yarn build && concurrently --kill-others --success first \"node cypress-spa-server.js > /dev/null\" \"cypress run --browser chrome\"",
2020
"cypress:open": "cypress open",
2121
"cypress:e2e": "cypress open --config-file cypress-e2e.json",
2222
"cypress:install": "cypress install"
@@ -81,6 +81,7 @@
8181
"eslint-plugin-import": "^2.2.0",
8282
"eventsource-polyfill": "^0.9.6",
8383
"extract-text-webpack-plugin": "^2.0.0",
84+
"express": "^4.17.1",
8485
"file-loader": "^0.11.1",
8586
"friendly-errors-webpack-plugin": "^1.1.3",
8687
"html-webpack-plugin": "^2.28.0",
@@ -113,7 +114,6 @@
113114
"shelljs": "^0.7.6",
114115
"sinon": "^7.3.2",
115116
"sinon-chai": "^3.2.0",
116-
"spa-http-server": "^0.9.0",
117117
"speed-measure-webpack-plugin": "^1.3.1",
118118
"timeshift-js": "^1.0.1",
119119
"url-loader": "^0.5.8",

0 commit comments

Comments
 (0)