Skip to content

Commit

Permalink
fix: pass in default channels in routes
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Oct 21, 2024
1 parent d1853f7 commit ecff89e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
10 changes: 3 additions & 7 deletions core/app/admin/route.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import { useLocale } from 'next-intl';

import { redirect } from '~/i18n/routing';
import { defaultLocale, redirect } from '~/i18n/routing';

const canonicalDomain: string = process.env.BIGCOMMERCE_GRAPHQL_API_DOMAIN ?? 'mybigcommerce.com';
const BIGCOMMERCE_STORE_HASH = process.env.BIGCOMMERCE_STORE_HASH;
const ENABLE_ADMIN_ROUTE = process.env.ENABLE_ADMIN_ROUTE;

export const GET = () => {
const locale = useLocale();

// This route should not work unless explicitly enabled
if (ENABLE_ADMIN_ROUTE !== 'true') {
return redirect({ href: '/', locale });
return redirect({ href: '/', locale: defaultLocale });
}

return redirect({
href: BIGCOMMERCE_STORE_HASH
? `https://store-${BIGCOMMERCE_STORE_HASH}.${canonicalDomain}/admin`
: 'https://login.bigcommerce.com',
locale,
locale: defaultLocale,
});
};

Expand Down
4 changes: 3 additions & 1 deletion core/app/sitemap.xml/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
* Proxy to the existing BigCommerce sitemap index on the canonical URL
*/

import { getChannelIdFromLocale } from '~/channels.config';
import { client } from '~/client';
import { defaultLocale } from '~/i18n/routing';

export const GET = async () => {
const sitemapIndex = await client.fetchSitemapIndex();
const sitemapIndex = await client.fetchSitemapIndex(getChannelIdFromLocale(defaultLocale));

return new Response(sitemapIndex, {
headers: {
Expand Down
8 changes: 2 additions & 6 deletions core/app/xmlsitemap.php/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable check-file/folder-naming-convention */
import { useLocale } from 'next-intl';

import { permanentRedirect } from '~/i18n/routing';
import { defaultLocale, permanentRedirect } from '~/i18n/routing';

/*
* This route is used to redirect the legacy Stencil sitemap that lives on /xmlsitemap.php
Expand All @@ -11,9 +9,7 @@ import { permanentRedirect } from '~/i18n/routing';
*/

export const GET = () => {
const locale = useLocale();

permanentRedirect({ href: '/sitemap.xml', locale });
permanentRedirect({ href: '/sitemap.xml', locale: defaultLocale });
};

export const runtime = 'edge';

0 comments on commit ecff89e

Please sign in to comment.