Skip to content
This repository was archived by the owner on Feb 27, 2025. It is now read-only.

Commit 8be816a

Browse files
author
Brent Schmidt
committed
fix: Move 'allowed-control-allow-origin' overwrite
1 parent 87a4fbd commit 8be816a

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

lib/commands/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,15 @@ const playback = {
190190
map.notifyRequestCompleted(id);
191191
// Make sure the browser does not try to use a cached response.
192192
res.headers['cache-control'] = 'no-cache';
193+
if (res.headers['access-control-allow-origin']) {
194+
// Allow all origins, as this respones may be played back on a
195+
// different origin.
196+
res.headers['access-control-allow-origin'] = '*';
197+
}
193198

194199
if (originalRequestData) {
195-
if (res.headers['access-control-allow-origin']) {
196-
res.headers['access-control-allow-origin'] = '*';
197-
}
198-
// Restore original request data, so that we persist the unmodified
199-
// values.
200+
// Restore original request data, so that we generate a response id
201+
// with unmodified values.
200202
req.url = originalRequestData.url;
201203
req.headers = originalRequestData.headers;
202204
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "Automatically record and playback HTTP requests made in Cypress tests.",
66
"scripts": {
77
"sandbox:open": "cd ./sandbox/ && npm run start:open",
8+
"sandbox:open:playback": "cd ./sandbox/ && npm run start:open:playback",
89
"sandbox:ci": "cd ./sandbox/ && npm run start:run"
910
},
1011
"repository": {
Binary file not shown.

sandbox/cypress/integration/app.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ describe('local to-do app', () => {
77
// at 8081 when recording and 8082 when playing back. This is to allow
88
// us to test the `matching.ignores` feature.
99
if (isRecording) {
10-
baseUrl = `http://localhost:${8081}/`;
10+
baseUrl = `http://localhost:8081/`;
1111
} else if (isPlayingBack) {
12-
baseUrl = `http://localhost:${8082}/`;
12+
baseUrl = `http://localhost:8082/`;
1313
}
1414
cy.log(`isPlayingBack: ${isPlayingBack}`);
1515
cy.log(`isRecording: ${isRecording}`);

sandbox/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "index.js",
77
"scripts": {
88
"start:open": "start-server-and-test 'http-server ./app --port=8081' 8081 'cypress open'",
9+
"start:open:playback": "CYPRESS_PLAYBACK_MODE=playback start-server-and-test 'http-server ./app --port=8082' 8082 'cypress open'",
910
"start:run": "start-server-and-test 'http-server ./app --port=8082' 8082 'cypress run'"
1011
},
1112
"keywords": [],

0 commit comments

Comments
 (0)