Skip to content

fix(seo): exclude robots.txt and sitemap.xml from auth middleware#83

Merged
balajmarius merged 1 commit into
mainfrom
fix/robots-and-sitemap-auth-redirect
May 27, 2026
Merged

fix(seo): exclude robots.txt and sitemap.xml from auth middleware#83
balajmarius merged 1 commit into
mainfrom
fix/robots-and-sitemap-auth-redirect

Conversation

@ErolP18
Copy link
Copy Markdown
Collaborator

@ErolP18 ErolP18 commented May 27, 2026

Lighthouse reports robots.txt as requiring authentication. The cause: the auth middleware's matcher does not exclude robots.txt or sitemap.xml, and PUBLIC_ROUTES does not list them either. Unauthenticated requests (every crawler, every Lighthouse run) hit the middleware, fail the isPublicRoute check, and get redirected to /auth/login — so bots see a login redirect instead of the robots policy.

Add robots.txt and sitemap.xml to the matcher's negative-lookahead exclusion, alongside favicon.ico. These are crawler metadata files; they must never go through Supabase auth, and the middleware has no reason to run for them at all. Same approach as the existing image/video exclusions.

Summary

Brief description of changes.

Changes

  • Change 1
  • Change 2

Claudebin Session

🔗 Session Link

Testing

How did you test this?

Checklist

  • bun check passes
  • bun type-check passes
  • Tested locally
  • Claudebin session link attached

Lighthouse reports robots.txt as requiring authentication. The cause:
the auth middleware's matcher does not exclude robots.txt or sitemap.xml,
and PUBLIC_ROUTES does not list them either. Unauthenticated requests
(every crawler, every Lighthouse run) hit the middleware, fail the
isPublicRoute check, and get redirected to /auth/login — so bots see a
login redirect instead of the robots policy.

Add robots.txt and sitemap.xml to the matcher's negative-lookahead
exclusion, alongside favicon.ico. These are crawler metadata files; they
must never go through Supabase auth, and the middleware has no reason
to run for them at all. Same approach as the existing image/video
exclusions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@balajmarius balajmarius merged commit c04f1d0 into main May 27, 2026
1 of 2 checks passed
@balajmarius balajmarius deleted the fix/robots-and-sitemap-auth-redirect branch May 27, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants