update redirect status codes across the entire app

main
TZGyn 1 year ago
parent fd499ebaff
commit 446b98db20
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit'
import type { PageServerLoad } from './$types' import type { PageServerLoad } from './$types'
export const load = (async () => { export const load = (async () => {
redirect(301, '/dashboard/billing') redirect(302, '/dashboard/billing')
}) satisfies PageServerLoad }) satisfies PageServerLoad

@ -8,10 +8,10 @@ import { eq } from 'drizzle-orm'
export const load = (async (events) => { export const load = (async (events) => {
if (events.locals.user.plan !== 'free') { if (events.locals.user.plan !== 'free') {
redirect(301, '/dashboard/billing') redirect(302, '/dashboard/billing')
} }
if (!events.locals.user.email_verified) { if (!events.locals.user.email_verified) {
redirect(301, '/dashboard/billing') redirect(302, '/dashboard/billing')
} }
const user = events.locals.user const user = events.locals.user
@ -47,8 +47,8 @@ export const load = (async (events) => {
}) })
if (!session.url) { if (!session.url) {
redirect(301, '/dashboard/billing') redirect(302, '/dashboard/billing')
} }
redirect(301, session.url) redirect(302, session.url)
}) satisfies PageServerLoad }) satisfies PageServerLoad

@ -10,14 +10,14 @@ export const load = (async ({ url }) => {
const session_id = url.searchParams.get('session_id') const session_id = url.searchParams.get('session_id')
const stripe = new Stripe(env.PRIVATE_STRIPE_SECRET_KEY) const stripe = new Stripe(env.PRIVATE_STRIPE_SECRET_KEY)
if (!session_id) redirect(301, '/dashboard/billing') if (!session_id) redirect(302, '/dashboard/billing')
const session = await stripe.checkout.sessions.retrieve(session_id) const session = await stripe.checkout.sessions.retrieve(session_id)
if ( if (
session.status === 'complete' && session.status === 'complete' &&
session.payment_status === 'paid' session.payment_status === 'paid'
) { ) {
if (!session.customer) redirect(301, '/dashboard/billing') if (!session.customer) redirect(302, '/dashboard/billing')
await db await db
.update(user) .update(user)
@ -26,6 +26,6 @@ export const load = (async ({ url }) => {
}) })
.where(eq(user.stripeCustomerId, session.customer?.toString())) .where(eq(user.stripeCustomerId, session.customer?.toString()))
redirect(301, '/dashboard/billing') redirect(302, '/dashboard/billing')
} }
}) satisfies PageServerLoad }) satisfies PageServerLoad

@ -74,8 +74,7 @@ export const actions: Actions = {
const redirectUrl = event.url.searchParams.get('redirect') const redirectUrl = event.url.searchParams.get('redirect')
if (redirectUrl) { if (redirectUrl) {
console.log(redirectUrl) redirect(302, redirectUrl)
redirect(301, redirectUrl)
} }
return { return {

@ -18,7 +18,7 @@ export const load = (async (event) => {
}) })
if (!shortener) { if (!shortener) {
redirect(301, `/dashboard/links`) redirect(302, `/dashboard/links`)
} }
let setting: { let setting: {

@ -105,7 +105,7 @@ func main() {
invalidUrl := fallbackurl + "/qr/invalid" invalidUrl := fallbackurl + "/qr/invalid"
app.Get("/", func(c *fiber.Ctx) error { app.Get("/", func(c *fiber.Ctx) error {
return c.Redirect(fallbackurl) return c.Redirect(fallbackurl, 301)
}) })
app.Get("/:code", func(c *fiber.Ctx) error { app.Get("/:code", func(c *fiber.Ctx) error {

Loading…
Cancel
Save