Skip to content

Commit

Permalink
fix: remove cross-origin
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Nov 6, 2024
1 parent 4d6f44a commit 7314c08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 8 additions & 8 deletions src/Server/__tests__/getWebpackEarlyHints.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ describe("getWebpackEarlyHints", () => {

expect(fs.readFileSync).toHaveBeenCalledWith(HINTS_PATH, "utf-8")
expect(result.linkHeaders).toEqual([
`<https://cdn.example.com/chunk1.js>; rel=preload; as=script; crossorigin`,
`<https://cdn.example.com/chunk2.js>; rel=preload; as=script; crossorigin`,
`<https://cdn.example.com/chunk1.js>; rel=preload; as=script`,
`<https://cdn.example.com/chunk2.js>; rel=preload; as=script`,
])
expect(result.linkPreloadTags).toEqual([
`<link rel="preload" as="script" href="https://cdn.example.com/chunk1.js" crossorigin>`,
`<link rel="preload" as="script" href="https://cdn.example.com/chunk2.js" crossorigin>`,
`<link rel="preload" as="script" href="https://cdn.example.com/chunk1.js">`,
`<link rel="preload" as="script" href="https://cdn.example.com/chunk2.js">`,
])
})

Expand All @@ -43,12 +43,12 @@ describe("getWebpackEarlyHints", () => {

expect(fs.readFileSync).toHaveBeenCalledWith(HINTS_PATH, "utf-8")
expect(result.linkHeaders).toEqual([
`</chunk1.js>; rel=preload; as=script; crossorigin`,
`</chunk2.js>; rel=preload; as=script; crossorigin`,
`</chunk1.js>; rel=preload; as=script`,
`</chunk2.js>; rel=preload; as=script`,
])
expect(result.linkPreloadTags).toEqual([
`<link rel="preload" as="script" href="/chunk1.js" crossorigin>`,
`<link rel="preload" as="script" href="/chunk2.js" crossorigin>`,
`<link rel="preload" as="script" href="/chunk1.js">`,
`<link rel="preload" as="script" href="/chunk2.js">`,
])
})
})
6 changes: 2 additions & 4 deletions src/Server/getWebpackEarlyHints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ export const getWebpackEarlyHints = (): {

const links = chunkFiles.reduce(
(acc, file) => {
acc.linkHeaders.push(
`<${cdnUrl}${file}>; rel=preload; as=script; crossorigin`
)
acc.linkHeaders.push(`<${cdnUrl}${file}>; rel=preload; as=script`)
acc.linkPreloadTags.push(
`<link rel="preload" as="script" href="${cdnUrl}${file}" crossorigin>`
`<link rel="preload" as="script" href="${cdnUrl}${file}">`
)
return acc
},
Expand Down

0 comments on commit 7314c08

Please sign in to comment.