Skip to content

Commit

Permalink
Remove env variable that would fallback to import.meta from Oxygen to…
Browse files Browse the repository at this point in the history
… hopefully prevent undefined env vars
  • Loading branch information
futurGH committed Dec 23, 2023
1 parent 752e54a commit 07cdee4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/lib/ReCaptcha.client.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { GoogleReCaptchaProvider } from "react-google-recaptcha-v3";
import type { ReactNode } from "react";

const env: Record<string, string> = typeof Oxygen !== "undefined" && "env" in Oxygen ? Oxygen.env : import.meta.env;

export function ReCaptcha({ children }: { children: ReactNode }) {
return <GoogleReCaptchaProvider reCaptchaKey={env.PUBLIC_RECAPTCHA_SITE_KEY}>{children}</GoogleReCaptchaProvider>;
export function ReCaptcha({ children, reCaptchaKey }: { children: ReactNode; reCaptchaKey: string }) {
return <GoogleReCaptchaProvider reCaptchaKey={reCaptchaKey}>{children}</GoogleReCaptchaProvider>;
}
5 changes: 2 additions & 3 deletions src/lib/gqlAdminApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// reference: https://github.com/Shopify/hydrogen/pull/1788/files#diff-4d536ffe12775c4364d272c9fb3d1675c5119d01cffec3e3cddd6b67bb299ade
const env: Record<string, string> = typeof Oxygen !== "undefined" && "env" in Oxygen ? Oxygen.env : import.meta.env;
export async function adminApiClient<T>(query: string, variables: Record<string, unknown> = {}): Promise<T> {
const endpoint = `https://${env.STOREFRONT_NAME}.myshopify.com/admin/api/${env.ADMIN_API_VERSION}/graphql.json`;
const endpoint = `https://${Oxygen.env.STOREFRONT_NAME}.myshopify.com/admin/api/${Oxygen.env.ADMIN_API_VERSION}/graphql.json`;
const response = await fetch(endpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": env.ADMIN_API_TOKEN,
"X-Shopify-Access-Token": Oxygen.env.ADMIN_API_TOKEN,
},
body: JSON.stringify({ query, variables }),
});
Expand Down
2 changes: 1 addition & 1 deletion src/routes/contact-us.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Contact() {
Got a question, comment, or just want to chat with someone about keyboards? Send us a message using
the form below.
</span>
<ReCaptcha>
<ReCaptcha reCaptchaKey={Oxygen.env.PUBLIC_RECAPTCHA_SITE_KEY}>
<ContactForm />
</ReCaptcha>
</Container>
Expand Down

0 comments on commit 07cdee4

Please sign in to comment.