shopify-nuxt 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shopify-nuxt",
3
3
  "configKey": "shopify",
4
- "version": "0.0.6",
4
+ "version": "0.0.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -35,14 +35,7 @@ const module$1 = defineNuxtModule({
35
35
  };
36
36
  nuxt.options.vite = nuxt.options.vite || {};
37
37
  nuxt.options.vite.server = nuxt.options.vite.server || {};
38
- const existing = nuxt.options.vite.server.allowedHosts;
39
- if (existing === true) ; else if (Array.isArray(existing)) {
40
- if (!existing.includes(".trycloudflare.com")) {
41
- existing.push(".trycloudflare.com");
42
- }
43
- } else {
44
- nuxt.options.vite.server.allowedHosts = [".trycloudflare.com"];
45
- }
38
+ nuxt.options.vite.server.allowedHosts = true;
46
39
  nuxt.options.alias["#shopify/server"] = resolver.resolve("./runtime/server");
47
40
  addServerImportsDir(resolver.resolve("./runtime/server/utils"));
48
41
  addImportsDir(resolver.resolve("./runtime/composables"));
@@ -52,13 +45,7 @@ const module$1 = defineNuxtModule({
52
45
  });
53
46
  nuxt.hook("app:resolve", () => {
54
47
  nuxt.options.app.head = nuxt.options.app.head || {};
55
- nuxt.options.app.head.meta = [
56
- {
57
- name: "content-security-policy",
58
- content: "frame-ancestors 'self' *.myshopify.com *.shopify.com *.trycloudflare.com"
59
- },
60
- ...nuxt.options.app.head.meta || []
61
- ];
48
+ nuxt.options.app.head.meta = [...nuxt.options.app.head.meta || []];
62
49
  nuxt.options.app.head.script = [
63
50
  // 1. Inline script to create the meta tag imperatively — guarantees it
64
51
  // exists in the DOM before the CDN script executes.
@@ -141,6 +128,9 @@ export {}
141
128
  nitroConfig.plugins.push(
142
129
  resolver.resolve("./runtime/server/plugins/shopify-defaults")
143
130
  );
131
+ nitroConfig.plugins.push(
132
+ resolver.resolve("./runtime/server/plugins/add-response-headers")
133
+ );
144
134
  });
145
135
  nuxt.options.build.transpile.push(resolver.resolve("./runtime"));
146
136
  nuxt.hook("nitro:config", (nitroConfig) => {
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Nitro plugin that adds Shopify-required response headers to every document request.
3
+ *
4
+ * Mirrors the behaviour of Shopify's official `addDocumentResponseHeaders`:
5
+ * - `Content-Security-Policy`: frame-ancestors scoped to the requesting shop
6
+ * - `Link`: preconnect / preload hints for App Bridge + Polaris CDN assets
7
+ *
8
+ * @see https://github.com/Shopify/shopify-app-js/blob/main/packages/apps/shopify-app-react-router/src/server/authenticate/helpers/add-response-headers.ts
9
+ */
10
+ declare const _default: import("nitropack/types").NitroAppPlugin;
11
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { defineNitroPlugin } from "nitropack/runtime";
2
+ import { getQuery, setResponseHeader } from "h3";
3
+ const APP_BRIDGE_URL = "https://cdn.shopify.com/shopifycloud/app-bridge.js";
4
+ const POLARIS_URL = "https://cdn.shopify.com/shopifycloud/polaris.js";
5
+ const CDN_URL = "https://cdn.shopify.com";
6
+ export default defineNitroPlugin((nitroApp) => {
7
+ nitroApp.hooks.hook("request", (event) => {
8
+ const query = getQuery(event);
9
+ const shop = typeof query.shop === "string" ? query.shop : void 0;
10
+ if (shop) {
11
+ setResponseHeader(
12
+ event,
13
+ "Link",
14
+ `<${CDN_URL}>; rel="preconnect", <${APP_BRIDGE_URL}>; rel="preload"; as="script", <${POLARIS_URL}>; rel="preload"; as="script"`
15
+ );
16
+ }
17
+ if (shop) {
18
+ setResponseHeader(
19
+ event,
20
+ "Content-Security-Policy",
21
+ `frame-ancestors https://${shop} https://admin.shopify.com https://*.spin.dev https://admin.myshopify.io https://admin.shop.dev;`
22
+ );
23
+ } else {
24
+ setResponseHeader(
25
+ event,
26
+ "Content-Security-Policy",
27
+ `frame-ancestors https://*.myshopify.com https://admin.shopify.com https://*.spin.dev https://admin.myshopify.io https://admin.shop.dev;`
28
+ );
29
+ }
30
+ });
31
+ });
@@ -4,5 +4,5 @@
4
4
  * If the user calls `configureShopify()` in their own server plugin,
5
5
  * it will override these defaults (configureShopify resets cached singletons).
6
6
  */
7
- declare const _default: any;
7
+ declare const _default: import("nitropack/types").NitroAppPlugin;
8
8
  export default _default;
@@ -1,3 +1,4 @@
1
+ import { defineNitroPlugin } from "nitropack/runtime";
1
2
  import { MemorySessionStorage } from "@shopify/shopify-app-session-storage-memory";
2
3
  import { configureShopify, getResolvedConfig } from "../services/shopify.js";
3
4
  export default defineNitroPlugin(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shopify-nuxt",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Shopify app integration for Nuxt - authentication, webhooks, billing, and App Bridge",
5
5
  "repository": "kiriminaja/shopify-nuxt",
6
6
  "license": "MIT",