Skip to content

Commit

Permalink
v2025 - Hotfixes (#148)
Browse files Browse the repository at this point in the history
[Bypassing branch protection to bring online shop hotfix]

* Fixed menu links

* Fixed cron key validation
  • Loading branch information
LobeTia authored Jan 20, 2025
1 parent 978f278 commit f638c35
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/app/api/cron/health-check/route.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { db } from "@/server/db"
import { headers } from "next/headers"
import type { NextRequest } from "next/server"
import { NextResponse } from "next/server"
import { env } from "@/env"

// Vercel cron job configuration
export const dynamic = "force-dynamic"
export const maxDuration = 59

export async function GET() {
export async function GET(request: NextRequest) {
try {
// Verify cron secret in production only
if (env.NODE_ENV === "production") {
const headersList = await headers()
const cronSecret = headersList.get("x-vercel-cron")
if (cronSecret !== env.CRON_SECRET) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
if (env.VERCEL_ENV === "production") {
const authHeader = request.headers.get("authorization")
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) {
return new Response("Unauthorized", {
status: 401,
})
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/organisms/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ export function Header() {
</Accordion>

<SheetClose asChild>
<Link href="/docs" className="text-sm font-medium transition-colors hover:text-primary">
<Link
href="https://shop.schroedinger-hat.org/"
className="text-sm font-medium transition-colors hover:text-primary"
>
<Typography variant="navigationMobile">Merch</Typography>
</Link>
</SheetClose>
Expand Down
2 changes: 2 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const env = createEnv({
*/
server: {
NODE_ENV: z.enum(["development", "test", "production"]),
VERCEL_ENV: z.enum(["development", "test", "production"]).optional(),
STRIPE_SECRET_KEY: z
.string()
.min(1)
Expand Down Expand Up @@ -48,6 +49,7 @@ export const env = createEnv({
*/
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
VERCEL_ENV: process.env.VERCEL_ENV,
STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY,
STRIPE_MEMBERSHIP_PRICE_ID: process.env.STRIPE_MEMBERSHIP_PRICE_ID,
NEXT_PUBLIC_SANITY_PROJECT_ID: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
Expand Down

0 comments on commit f638c35

Please sign in to comment.