From 875094e7182de75949258e23119639103a422869 Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Tue, 28 Mar 2023 18:52:13 -0400 Subject: [PATCH] Move redirects to fix SPA rewrite --- server/upstream/upstream.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/upstream/upstream.go b/server/upstream/upstream.go index afba8d4..f97c6ae 100644 --- a/server/upstream/upstream.go +++ b/server/upstream/upstream.go @@ -104,6 +104,12 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client, redi // Handle not found error if err != nil && errors.Is(err, gitea.ErrorNotFound) { + // Get and match redirects + redirects := o.getRedirects(giteaClient, redirectsCache) + if o.matchRedirects(ctx, giteaClient, redirects, redirectsCache) { + return true + } + if o.TryIndexPages { // copy the o struct & try if an index page exists optionsForIndexPages := *o @@ -138,9 +144,7 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client, redi } } - // Get and match redirects - redirects := o.getRedirects(giteaClient, redirectsCache) - return o.matchRedirects(ctx, giteaClient, redirects, redirectsCache) + return false } // handle unexpected client errors