Skip to content

Commit

Permalink
Add CORS support to widget
Browse files Browse the repository at this point in the history
  • Loading branch information
JackYoustra authored and laymonage committed Feb 11, 2024
1 parent a8fcda0 commit 714fdb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ writing, this is a rolling-release project without any meaningful versioning
whatsoever. Tags/releases may be created for the sole purpose of documenting
major updates to the project.

## 2024-02-11

### Added

- Add Cross-Origin Resource Policy support
([#1309](https://github.com/giscus/giscus/pull/1309)).

## 2024-02-10

### Added
Expand Down
3 changes: 3 additions & 0 deletions pages/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export async function getServerSideProps({ query, res }: GetServerSidePropsConte

const repoConfig = await getRepoConfig(repo, token);

// Opt into CORS. See: https://web.dev/articles/coop-coep
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');

if (!assertOrigin(originHost, repoConfig)) {
res.setHeader('Content-Security-Policy', `frame-ancestors 'none';`);
res.setHeader('X-Frame-Options', 'DENY');
Expand Down

0 comments on commit 714fdb9

Please sign in to comment.