Skip to content

Commit 1c1fdd1

Browse files
committed
Fix Capacitor build: skip OAuth redirects during static build
The adapter-static fallback generation was failing with status 302 because hooks.server.ts was triggering OAuth redirects during the build phase. Added a check for the `building` flag to skip these redirects during static site generation.
1 parent aa6e992 commit 1c1fdd1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/hooks.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ export const handle: Handle = async ({ event, resolve }) => {
144144
event.locals.sessionId = auth.sessionId;
145145

146146
if (loginEnabled && !auth.user && !event.url.pathname.startsWith(`${base}/.well-known/`)) {
147-
if (config.AUTOMATIC_LOGIN === "true") {
147+
// Skip OAuth redirects during static builds (Capacitor fallback generation)
148+
if (building) {
149+
// Allow the request to proceed without authentication during build
150+
} else if (config.AUTOMATIC_LOGIN === "true") {
148151
// AUTOMATIC_LOGIN: always redirect to OAuth flow (unless already on login or healthcheck pages)
149152
if (
150153
!event.url.pathname.startsWith(`${base}/login`) &&

0 commit comments

Comments
 (0)