fix(storefront): robust shop detection for widget
Made-with: Cursor
This commit is contained in:
parent
23d3165cc7
commit
2a4ab2a749
@ -144,7 +144,12 @@ export async function PATCH(
|
||||
// Even if ScriptTag operations fail (missing scopes), the widget still
|
||||
// won’t render because /api/storefront-chat/config returns the flag.
|
||||
try {
|
||||
const appBaseUrl = (process.env.NEXT_PUBLIC_APP_URL || "").trim()
|
||||
const appBaseUrl = (
|
||||
process.env.NEXT_PUBLIC_APP_URL ||
|
||||
process.env.AUTH_URL ||
|
||||
process.env.NEXTAUTH_URL ||
|
||||
""
|
||||
).trim()
|
||||
const apiVersion = "2024-01"
|
||||
const injectorBase = appBaseUrl ? appBaseUrl.replace(/\/$/, "") : ""
|
||||
|
||||
|
||||
@ -11,7 +11,11 @@ export async function GET() {
|
||||
try {
|
||||
var script = document.currentScript;
|
||||
var baseUrl = script && script.src ? new URL(script.src).origin : window.location.origin;
|
||||
var shop = window.location.hostname;
|
||||
// Prefer Shopify-provided shop identifier when available.
|
||||
// On custom domains, window.location.hostname won't match the shop's myshopify domain.
|
||||
var shop =
|
||||
(window.Shopify && (window.Shopify.shop || window.Shopify.myshopifyDomain)) ||
|
||||
window.location.hostname;
|
||||
|
||||
var containerId = "juno-storefront-chat-container";
|
||||
var iframeId = "juno-storefront-chat-iframe";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user