Move redirects to fix SPA rewrite

This commit is contained in:
video-prize-ranch 2023-03-28 18:52:13 -04:00
parent fa769b728e
commit 875094e718
No known key found for this signature in database

View file

@ -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