Skip to content

fix: redirect swagger fixed - #1572

Open
joaoMiraya wants to merge 5 commits into
credebl:mainfrom
joaoMiraya:fix/swagger-route
Open

fix: redirect swagger fixed#1572
joaoMiraya wants to merge 5 commits into
credebl:mainfrom
joaoMiraya:fix/swagger-route

Conversation

@joaoMiraya

@joaoMiraya joaoMiraya commented Feb 25, 2026

Copy link
Copy Markdown

Redirect http://localhost:5000 -> http://localhost:5000/api when's development mode

Issue

Summary by CodeRabbit

  • New Features
    • Added a root endpoint that redirects to the API documentation when Swagger is enabled.
    • Added graceful fallback behavior when API documentation is unavailable, returning a successful response without a redirect.
    • Enabled Swagger by default in the demo environment, making API documentation readily accessible for demonstration and testing.

Signed-off-by: joaoMiraya <joaomiraya01@gmail.com>
@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@joaoMiraya, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 720b25c9-285c-4792-8363-60c6f528c12c

📥 Commits

Reviewing files that changed from the base of the PR and between 412adf6 and 6e1b498.

📒 Files selected for processing (1)
  • .env.demo

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 97792039-c0ab-40b5-b79b-5fe92dfb12cf

📥 Commits

Reviewing files that changed from the base of the PR and between 7dcb84c and 412adf6.

📒 Files selected for processing (1)
  • .env.demo

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The API gateway now conditionally redirects the root route to /api when Swagger is enabled. ConfigService exposes the ENABLE_SWAGGER setting as a boolean, and .env.demo enables Swagger.

Changes

Swagger redirect

Layer / File(s) Summary
Swagger availability configuration
libs/config/src/config.service.ts, .env.demo
ConfigService exposes isSwaggerAvailable based on whether ENABLE_SWAGGER equals 'true'. .env.demo sets ENABLE_SWAGGER=true.
Conditional Swagger route
apps/api-gateway/src/app.controller.ts
AppController injects ConfigService and adds a Swagger-excluded root GET route. The route returns a 302 redirect to /api when Swagger is available and status 200 otherwise.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 412ad

This localized redirect change has no actionable merge-blocking risk remaining beyond normal checks and review.

Suggested reviewers: rinkalbhojani, tipusinghaw

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies the main change: fixing the Swagger redirect route.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/swagger-route
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@RinkalBhojani

Copy link
Copy Markdown
Contributor

@joaoMiraya - Thanks for your contribution.

I have one suggestion.

Instead of limiting the Swagger UI redirect to development mode only, I think it would be better to make it configurable through some different flag in .env file. That way, users can decide which environments they want to expose the Swagger endpoint in.

For example, if someone wants to enable it in production for their own use case, they should be able to do so. This keeps the default behavior safe while giving users the flexibility to configure it based on their needs.

Signed-off-by: joaoMiraya <joaomiraya01@gmail.com>
@joaoMiraya

Copy link
Copy Markdown
Author

@joaoMiraya - Thanks for your contribution.

I have one suggestion.

Instead of limiting the Swagger UI redirect to development mode only, I think it would be better to make it configurable through some different flag in .env file. That way, users can decide which environments they want to expose the Swagger endpoint in.

For example, if someone wants to enable it in production for their own use case, they should be able to do so. This keeps the default behavior safe while giving users the flexibility to configure it based on their needs.

Its looks great, i gonna make it

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api-gateway/src/app.controller.ts (1)

16-17: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Avoid a permanent redirect for a runtime-configurable feature.

A 301 is heuristically cacheable; clients or proxies can retain /api after ENABLE_SWAGGER is later disabled. Use a temporary redirect such as 302/307, or explicitly prevent caching. (rfc-editor.org)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api-gateway/src/app.controller.ts` around lines 16 - 17, Update the root
route’s `@Redirect` in the controller to use a temporary redirect status, such as
302 or 307, instead of the permanent 301 so runtime configuration changes are
not cached by clients or proxies.

Source: MCP tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.env.sample:
- Around line 275-277: Update the ENABLE_SWAGGER setting in the generic
environment sample to false or remove it, ensuring Swagger is not enabled by
default; retain true only in explicitly demo or development templates.

In `@libs/config/src/config.service.ts`:
- Around line 29-30: Update the isSwaggerAvailable getter in ConfigService to
normalize the ENABLE_SWAGGER environment value at runtime, converting string
values such as "false" to boolean false before returning it. Preserve true
behavior for enabled values and ensure the root redirect does not treat the
string "false" as truthy.

---

Outside diff comments:
In `@apps/api-gateway/src/app.controller.ts`:
- Around line 16-17: Update the root route’s `@Redirect` in the controller to use
a temporary redirect status, such as 302 or 307, instead of the permanent 301 so
runtime configuration changes are not cached by clients or proxies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ef8721b9-401b-4977-8785-1923ddd96c4b

📥 Commits

Reviewing files that changed from the base of the PR and between c94f7ca and 77773e9.

📒 Files selected for processing (4)
  • .env.demo
  • .env.sample
  • apps/api-gateway/src/app.controller.ts
  • libs/config/src/config.service.ts

Comment thread .env.sample Outdated
Comment thread libs/config/src/config.service.ts Outdated
Signed-off-by: joaoMiraya <joaomiraya01@gmail.com>
@ankita-p17

Copy link
Copy Markdown
Contributor

Hi @joaoMiraya,
Please update .env.demo as well with new variable that you've added.
We are looking forward to approving your contribution & taking it in upcoming release!

joaoMiraya and others added 2 commits August 19, 2026 22:03
Signed-off-by: joaoMiraya <joaomiraya01@gmail.com>
Signed-off-by: João  Victor B Miraya <108498460+joaoMiraya@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@joaoMiraya

Copy link
Copy Markdown
Author

Hi @joaoMiraya, Please update .env.demo as well with new variable that you've added. We are looking forward to approving your contribution & taking it in upcoming release!

Hello, It's done

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.

3 participants