Website hub for the atmosphere community, aggregating posts, events, regional, and more
569 B
14 lines
1import { defineMiddleware } from "astro:middleware";
2
3// Keep dev traffic on 127.0.0.1: ATProto OAuth callbacks always come back on
4// 127.0.0.1, so a stray localhost session ends up with cookies on a different
5// origin than the post-login session — login appears to silently fail.
6export const onRequest = defineMiddleware(async (context, next) => {
7 if (import.meta.env.DEV && context.url.hostname === "localhost") {
8 const url = new URL(context.url);
9 url.hostname = "127.0.0.1";
10 return context.redirect(url.toString(), 307);
11 }
12
13 return next();
14});