Skip to content

Commit

Permalink
fix(core): manually pass in channel id for get favicon query
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed Sep 13, 2024
1 parent f37deb6 commit 02bed8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-coats-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Pass in default channel to favicon query, since `getLocale` can't be used in routes.
7 changes: 5 additions & 2 deletions core/app/favicon.ico/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
*
*/

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

const GET_FAVICON_QUERY = graphql(`
const GetFaviconQuery = graphql(`
query GetFavicon {
site {
settings {
Expand All @@ -24,7 +26,8 @@ const GET_FAVICON_QUERY = graphql(`

export const GET = async () => {
const { data } = await client.fetch({
document: GET_FAVICON_QUERY,
document: GetFaviconQuery,
channelId: getChannelIdFromLocale(defaultLocale),
});

const faviconUrl = data.site.settings?.faviconUrl;
Expand Down
2 changes: 1 addition & 1 deletion core/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const client = createClient({
return getChannelIdFromLocale(locale) ?? defaultChannelId;
} catch {
// eslint-disable-next-line no-console
console.error('Error using `getLocale`, using default channel id instead.');
console.error('Warning: issue using `getLocale`, using default channel id instead.');

return defaultChannelId;
}
Expand Down

0 comments on commit 02bed8d

Please sign in to comment.