Skip to content

Commit

Permalink
add nocors
Browse files Browse the repository at this point in the history
  • Loading branch information
yunakim714 committed Sep 25, 2024
1 parent 8322473 commit 0ba4da2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/static/helpers/slasHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ export async function authorize(

// set manual redirect on server since node allows access to the location
// header and it skips the extra call. In the browser, only the default
// set manual redirect for external idp login so shoppers can grab the authorization url
// follow setting allows us to get the url.
/* istanbul ignore next */
slasClientCopy.clientConfig.fetchOptions = {
...slasClient.clientConfig.fetchOptions,
redirect: isBrowser ? 'follow' : 'manual',
mode: 'no-cors',
};

const options = {
Expand All @@ -148,6 +150,7 @@ export async function authorize(
const redirectUrlString = response.headers?.get('location') || response.url;
const redirectUrl = new URL(redirectUrlString);
const searchParams = Object.fromEntries(redirectUrl.searchParams.entries());
const {headers} = response;

Check warning on line 153 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (12)

'headers' is assigned a value but never used

Check warning on line 153 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (14)

'headers' is assigned a value but never used

Check warning on line 153 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (16)

'headers' is assigned a value but never used

Check warning on line 153 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (18)

'headers' is assigned a value but never used

// url is a read only property we unfortunately cannot mock out using nock
// meaning redirectUrl will not have a falsy value for unit tests
Expand All @@ -156,7 +159,10 @@ export async function authorize(
throw new ResponseError(response);
}

return {url: redirectUrlString, ...getCodeAndUsidFromUrl(redirectUrlString)};
return {
url: redirectUrlString,
...getCodeAndUsidFromUrl(redirectUrlString)

Check warning on line 164 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (12)

Insert `,`

Check warning on line 164 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (14)

Insert `,`

Check warning on line 164 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (16)

Insert `,`

Check warning on line 164 in src/static/helpers/slasHelper.ts

View workflow job for this annotation

GitHub Actions / linux-tests (18)

Insert `,`
};
}

/**
Expand Down

0 comments on commit 0ba4da2

Please sign in to comment.