Skip to content

Commit 10171d4

Browse files
committed
refactor: update meta tag handling in Nuxt module and improve CSP header test
1 parent 6f37605 commit 10171d4

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/module.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ export default defineNuxtModule<ModuleOptions>({
8484
// The meta tag MUST appear before the App Bridge script — it reads the API key on load.
8585
nuxt.hook('app:resolve', () => {
8686
nuxt.options.app.head = nuxt.options.app.head || {}
87-
nuxt.options.app.head.meta = [
88-
...(nuxt.options.app.head.meta || [])
89-
]
87+
nuxt.options.app.head.meta = [...(nuxt.options.app.head.meta || [])]
9088
nuxt.options.app.head.script = [
9189
// 1. Inline script to create the meta tag imperatively — guarantees it
9290
// exists in the DOM before the CDN script executes.

test/basic.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createHmac } from 'node:crypto'
22
import { fileURLToPath } from 'node:url'
33
import { describe, it, expect } from 'vitest'
4-
import { setup, $fetch } from '@nuxt/test-utils/e2e'
4+
import { setup, $fetch, url } from '@nuxt/test-utils/e2e'
55

66
const TEST_API_KEY = 'test-api-key'
77
const TEST_API_SECRET = 'test-api-secret'
@@ -44,9 +44,10 @@ describe('shopify-nuxt module', async () => {
4444
expect(html).toContain('cdn.shopify.com/shopifycloud/polaris')
4545
})
4646

47-
it('includes CSP frame-ancestors meta tag', async () => {
48-
const html = await $fetch('/')
49-
expect(html).toContain('frame-ancestors')
47+
it('includes CSP frame-ancestors header', async () => {
48+
const res = await fetch(url('/'))
49+
const csp = res.headers.get('content-security-policy')
50+
expect(csp).toContain('frame-ancestors')
5051
})
5152
})
5253

0 commit comments

Comments
 (0)