From 6d482354c114e9cd72bd988ff7bb3dc20af4baa7 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Mon, 27 Apr 2026 01:35:51 +0700 Subject: [PATCH] fix(deploy): break the / -> / redirect loop on Cloudflare Pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous rule "/* / 301" matched / itself even though docs say static assets take precedence — empirically CF still bounced and caused ERR_TOO_MANY_REDIRECTS on loto.miti99.com. Replace with two safer rules: /master* / 301 (true URL redirect for the known orphan) /* /index.html 200 (SPA fallback — URL stays, homepage shows) The 200 rewrite cannot create a redirect loop. Static assets at /, /_app/*, /favicon.* are served before rules fire. --- static/_redirects | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/static/_redirects b/static/_redirects index 2c0452d..1bf4f9b 100644 --- a/static/_redirects +++ b/static/_redirects @@ -1,4 +1,10 @@ -# Cloudflare Pages: any unknown path → 301 redirect to homepage. -# Static asset files are served first, so this only fires on misses. -# Keeps old /master bookmarks (and any future stray URL) on the app. -/* / 301 +# Cloudflare Pages routing rules. +# +# 1. /master* → 301 redirect to / (handles old bookmarks from when the +# host had its own page; the URL bar updates to /). +# 2. /* → 200 rewrite to /index.html (SPA fallback for any other unknown +# path: keeps the URL but serves the homepage content). Static assets +# take precedence over rules, so /, /_app/*, /favicon.ico, etc. are +# served directly without rewrite — no redirect loop on /. +/master* / 301 +/* /index.html 200