fix(products): fix view-in-site URL to use canonical apex domain instead of www
This commit is contained in:
1 parent
73029c06c4
commit
9efa96be9b
3 files changed
+620
-615
No files matched your search
@@ -88,9 +88,14 @@ export default function Products() {
|
||||
if (isDev) {
|
||||
return `http://localhost:4005/shop/${slug}`;
|
||||
}
|
||||
// Production fallback based on actual URL
|
||||
const storeOrigin = window.location.origin.replace('admin', 'www');
|
||||
return `${storeOrigin}/shop/${slug}`;
|
||||
// Check environment variable or resolve clean domain from window.location
|
||||
const envSiteUrl = import.meta.env.VITE_SITE_URL || import.meta.env.VITE_STORE_URL;
|
||||
if (envSiteUrl) {
|
||||
return `${envSiteUrl.replace(/\/$/, '')}/shop/${slug}`;
|
||||
}
|
||||
// Remove admin. subdomain (e.g. https://admin.canina.ir -> https://canina.ir)
|
||||
const host = window.location.host.replace(/^admin\./, '');
|
||||
return `${window.location.protocol}//${host}/shop/${slug}`;
|
||||
};
|
||||
|
||||
const slugify = (text: string) => {
|
||||
|
||||
Reference in new issue
Block a user