Skip to content

Commit

Permalink
Merge pull request #381 from Shopify/fix_csp_headers_express_package
Browse files Browse the repository at this point in the history
Fixing CSP headers for internal Shopify use
  • Loading branch information
paulomarg authored Jul 31, 2023
2 parents 7f46021 + 0c46a39 commit a5eea84
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-pans-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/shopify-app-express': patch
---

Fixing CSP header for internal Shopify use
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TESTS: {
[TEST_SHOP, 12345, undefined].forEach((shop) => {
let expectedCSP = `frame-ancestors 'none';`;
if (isEmbeddedApp && typeof shop === 'string') {
expectedCSP = `frame-ancestors https://${shop} https://admin.shopify.com;`;
expectedCSP = `frame-ancestors https://${shop} https://admin.shopify.com https://*.spin.dev;`;
}
TESTS.push({shop, isEmbeddedApp, expectedCSP});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('ensureInstalledOnShop', () => {
},
});
expect(response.headers['content-security-policy']).toEqual(
`frame-ancestors https://${TEST_SHOP} https://admin.shopify.com;`,
`frame-ancestors https://${TEST_SHOP} https://admin.shopify.com https://*.spin.dev;`,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function addCSPHeader(api: Shopify, req: Request, res: Response) {
'Content-Security-Policy',
`frame-ancestors https://${encodeURIComponent(
shop,
)} https://admin.shopify.com;`,
)} https://admin.shopify.com https://*.spin.dev;`,
);
} else {
res.setHeader('Content-Security-Policy', `frame-ancestors 'none';`);
Expand Down

0 comments on commit a5eea84

Please sign in to comment.