T4: Fix gateway routing for Identity service#66
T4: Fix gateway routing for Identity service#66devin-ai-integration[bot] wants to merge 1 commit into
Conversation
The Identity service controller uses [Route("api/[controller]")] which
expects the full /api/identity prefix. Removing the PathRemovePrefix
transform so the gateway forwards the original path as-is.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| "Match": { "Path": "/api/identity/{**catch-all}" } | ||
| }, | ||
| "customer-route": { | ||
| "ClusterId": "customer-cluster", |
There was a problem hiding this comment.
🚩 Other service routes may have the same prefix-stripping mismatch that was fixed here for identity
The identity route's PathRemovePrefix was removed because the Identity service controller uses [Route("api/[controller]")] (IdentityController.cs:9), which means it expects the full path /api/identity/.... The same pattern applies to the other services — for example, CustomerController uses [Route("api/[controller]")] (Customer.API/Controllers/CustomerController.cs:6), resolving to api/customer (singular). But the gateway matches /api/customers/ (plural) and strips that prefix, forwarding bare paths like / or /{id} to the customer service, which expects api/customer/.... This means the customer, order, product, and notification routes likely have the same bug that was just fixed for identity — the PathRemovePrefix transforms would result in 404s unless those services use different route prefixes or the controller names happen to match the plural gateway paths. Worth verifying whether the remaining four routes need the same fix.
(Refers to lines 16-34)
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Valid observation — the other service routes may indeed have similar routing mismatches (especially the plural/singular discrepancy like /api/customers/ vs api/customer). However, this PR is intentionally scoped to the identity route only per task requirements. The other routes should be evaluated and fixed in a separate PR.
Summary
Remove the
PathRemovePrefixtransform from theidentity-routeinsrc/ApiGateway/appsettings.json.The Identity service controller uses
[Route("api/[controller]")], so it expects the full/api/identity/…prefix on incoming requests. ThePathRemovePrefix: "/api/identity"transform was stripping that prefix before forwarding, causing the service to receive bare paths like/logininstead of/api/identity/login— resulting in 404s."identity-route": { "ClusterId": "identity-cluster", - "Match": { "Path": "/api/identity/{**catch-all}" }, - "Transforms": [{ "PathRemovePrefix": "/api/identity" }] + "Match": { "Path": "/api/identity/{**catch-all}" } }Verified via docker compose:
register,login, and401on/userswithout token all work correctly through the gateway atlocalhost:5000.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/0f07b7a8f1014aec962930431c54da9f
Requested by: @mbatchelor81