Skip to content

middleware.ts calls /api/v1/auth/me on top of NEXT_PUBLIC_API_URL as-is, so a base URL ending in /api or /api/v1 makes every protected page return 503 #1653

Closed

Description

@mftee

Where

frontend/middleware.ts:8-13,196-230,276

Problem

The middleware builds ${API_BASE}/api/v1/auth/me from the raw NEXT_PUBLIC_API_URL. lib/api-config.ts explicitly accepts values ending in /api or /api/v1 and normalizes them, so a deployment configured as https://api.example.com/api/v1 works for client calls. The middleware then requests /api/v1/api/v1/auth/me, gets a 404, maps it to unavailable, and returns a plain-text 503 "Authentication service unavailable" for every protected route.

Suggested fix

Import apiUrl and normalizeConfiguredBase from lib/api-config.ts (the code is edge-safe) instead of re-deriving the base, and add middleware unit tests for each env var form.

Acceptance criteria

  • Protected pages load with NEXT_PUBLIC_API_URL set to the origin, /api or /api/v1

Activity

  1. added
    bug
    on Nov 18, 2026
  2. added
    Stellar Wave
    on Nov 20, 2026
  3. gbolly122 commented on Nov 20, 2026

    @gbolly122

    @gbolly122 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    Hi Maintainer I would love to work on this issue!

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @gbolly122 to this issue.

  4. NteinPrecious commented on Nov 20, 2026

    @NteinPrecious
    Contributor

    @NteinPrecious has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

    Hi there, I'd like to contribute to this.

    I've worked on blockchain and Web3 projects, including Stellar and Soroban smart contracts, alongside traditional full-stack web development. I'm comfortable moving between frontend, backend, and on-chain work.

    I've reviewed the issue and I'm confident I can implement a solid solution while following the project's conventions.

    Please assign this issue to me, I'd be happy to contribute.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @NteinPrecious to this issue.

  5. drips-wave commented on Nov 20, 2026

    @drips-wave

    Congratulations, @NteinPrecious! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

    🧑‍💻 @NteinPrecious: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  6. grantfox-oss commented on Nov 20, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @NteinPrecious's PR #1718 was approved and merged by @mftee.

    🏆 @NteinPrecious: You earned 40 FoxPoints for this contribution! Your current tier: Builder (2,908 total points). Track your full progress on GrantFox.

    👏 Great work, @NteinPrecious! Keep contributing to CodeGirlsInc.

  7. drips-wave commented on Nov 20, 2026

    @drips-wave

    This issue has been completed by @NteinPrecious as part of the Stellar Wave Program's 11th Wave 🥳

    😎 @NteinPrecious: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavebugfrontendnextjs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions