Skip to content

Commit

Permalink
fix: re-enable helmet for auth captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Jan 10, 2025
1 parent 562b09e commit 629323b
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/routes/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { Helmet } from 'react-helmet-async';

import { Outlet, createFileRoute, redirect } from '@tanstack/react-router';

import { RECAPTCHA_SITE_KEY } from '@/config/env';

export const Route = createFileRoute('/auth')({
head: () => {
if (RECAPTCHA_SITE_KEY) {
return {
links: [{ rel: 'pre-connect', href: 'https://www.google.com' }],
scripts: [
{
defer: true,
src: `https://www.google.com/recaptcha/api.js?render=${RECAPTCHA_SITE_KEY}`,
},
],
};
}
return {};
},
beforeLoad: ({ context }) => {
// check if the user is authenticated.
// if already authenticated, redirect to `/account`
Expand All @@ -30,5 +18,23 @@ export const Route = createFileRoute('/auth')({
});

function RouteComponent() {
return <Outlet />;
return (
<>
<Helmet>
{
// only add these tags if the env var is defined
RECAPTCHA_SITE_KEY && (
<>
<link rel="pre-connect" href="https://www.google.com" />
<script
defer
src={`https://www.google.com/recaptcha/api.js?render=${RECAPTCHA_SITE_KEY}`}
/>
</>
)
}
</Helmet>
<Outlet />
</>
);
}

0 comments on commit 629323b

Please sign in to comment.