Skip to content

fix: match scribe route prefix to subdomain API routing#205

Merged
ManukMinasyan merged 1 commit intomainfrom
fix/empty-api-docs-page
Mar 31, 2026
Merged

fix: match scribe route prefix to subdomain API routing#205
ManukMinasyan merged 1 commit intomainfrom
fix/empty-api-docs-page

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Contributor

Summary

  • When API_DOMAIN is set (production), API routes are registered on a subdomain without the api/ prefix — paths become v1/* instead of api/v1/*
  • Scribe's route prefix was hardcoded to api/v1/*, so it found zero matching routes and generated an empty OpenAPI spec (paths: [])
  • Made the prefix dynamic: v1/* when API_DOMAIN is set, api/v1/* otherwise

Regression introduced by #200.

Test plan

  • Added 2 tests in SubdomainRoutingTest verifying Scribe config prefix matches in both modes
  • Verified scribe:generate with API_DOMAIN set discovers all 32 endpoints (was 0)
  • Verified scribe:generate without API_DOMAIN still works correctly
  • After deploying, run php artisan scribe:generate in production to regenerate the spec

Copilot AI review requested due to automatic review settings March 31, 2026 13:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Scribe route discovery when API routes are served from a dedicated API subdomain (no /api path prefix), preventing empty OpenAPI specs in production when API_DOMAIN is set.

Changes:

  • Make Scribe’s routes.match.prefixes conditional on app.api_domain (v1/* vs api/v1/*).
  • Add feature tests asserting the Scribe config prefix matches the active routing mode.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
config/scribe.php Dynamically selects Scribe’s route prefix matcher based on whether API subdomain routing is enabled.
tests/Feature/Routing/SubdomainRoutingTest.php Adds tests verifying Scribe config prefix aligns with both path-based and subdomain-based API routing.

@ManukMinasyan ManukMinasyan merged commit b322ea4 into main Mar 31, 2026
14 checks passed
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