Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated header regex #3658

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli-kit/src/private/node/api/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ describe('common API methods', () => {
})
})

test('when using a custom app token, omit Bearer from auth headers', () => {
test.each(['shpat', 'shpua', 'shpca'])(`when custom app token starts with %s, do not prepend 'Bearer'`, (prefix) => {
// Given
vi.mocked(randomUUID).mockReturnValue('random-uuid')
vi.mocked(firstPartyDev).mockReturnValue(false)
const token = 'shpat_my_token'
const token = `${prefix}_my_token`
// When
const headers = buildHeaders(token)

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-kit/src/private/node/api/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function buildHeaders(token?: string): {[key: string]: string} {
...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),
}
if (token) {
const authString = token.match(/^shp(at|ua)/) ? token : `Bearer ${token}`
const authString = token.match(/^shp(at|ua|ca)/) ? token : `Bearer ${token}`
// eslint-disable-next-line dot-notation
headers['authorization'] = authString
headers['X-Shopify-Access-Token'] = authString
Expand Down