Skip to content

Commit

Permalink
fix: Move 'allowed-control-allow-origin' overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
tvsbrent committed Feb 4, 2022
1 parent 87a4fbd commit 8be816a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/commands/index.js
Expand Up @@ -190,13 +190,15 @@ const playback = {
map.notifyRequestCompleted(id);
// Make sure the browser does not try to use a cached response.
res.headers['cache-control'] = 'no-cache';
if (res.headers['access-control-allow-origin']) {
// Allow all origins, as this respones may be played back on a
// different origin.
res.headers['access-control-allow-origin'] = '*';
}

if (originalRequestData) {
if (res.headers['access-control-allow-origin']) {
res.headers['access-control-allow-origin'] = '*';
}
// Restore original request data, so that we persist the unmodified
// values.
// Restore original request data, so that we generate a response id
// with unmodified values.
req.url = originalRequestData.url;
req.headers = originalRequestData.headers;
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -5,6 +5,7 @@
"description": "Automatically record and playback HTTP requests made in Cypress tests.",
"scripts": {
"sandbox:open": "cd ./sandbox/ && npm run start:open",
"sandbox:open:playback": "cd ./sandbox/ && npm run start:open:playback",
"sandbox:ci": "cd ./sandbox/ && npm run start:run"
},
"repository": {
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions sandbox/cypress/integration/app.spec.js
Expand Up @@ -7,9 +7,9 @@ describe('local to-do app', () => {
// at 8081 when recording and 8082 when playing back. This is to allow
// us to test the `matching.ignores` feature.
if (isRecording) {
baseUrl = `http://localhost:${8081}/`;
baseUrl = `http://localhost:8081/`;
} else if (isPlayingBack) {
baseUrl = `http://localhost:${8082}/`;
baseUrl = `http://localhost:8082/`;
}
cy.log(`isPlayingBack: ${isPlayingBack}`);
cy.log(`isRecording: ${isRecording}`);
Expand Down
1 change: 1 addition & 0 deletions sandbox/package.json
Expand Up @@ -6,6 +6,7 @@
"main": "index.js",
"scripts": {
"start:open": "start-server-and-test 'http-server ./app --port=8081' 8081 'cypress open'",
"start:open:playback": "CYPRESS_PLAYBACK_MODE=playback start-server-and-test 'http-server ./app --port=8082' 8082 'cypress open'",
"start:run": "start-server-and-test 'http-server ./app --port=8082' 8082 'cypress run'"
},
"keywords": [],
Expand Down

0 comments on commit 8be816a

Please sign in to comment.