Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2025 - Hotfixes #148

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading