feat(product): T4 — fix gateway routing for product service#68
feat(product): T4 — fix gateway routing for product service#68devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Add PathPrefix /api/product after PathRemovePrefix /api/products so the gateway correctly rewrites: /api/products → /api/product /api/products/123 → /api/product/123 /api/products/categories → /api/product/categories Previously the strip-only transform forwarded to / which returned 404.
🤖 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:
|
| "Transforms": [ | ||
| { "PathRemovePrefix": "/api/products" }, | ||
| { "PathPrefix": "/api/product" } | ||
| ] |
There was a problem hiding this comment.
🚩 Other gateway routes have the same prefix mismatch that this PR only fixes for the product route
This PR adds a PathPrefix: "/api/product" transform to the product-route to correctly forward requests to the ProductController at api/Product. However, all other routes have the same structural issue: the gateway strips the prefix (e.g. /api/customers) leaving just the remainder (e.g. /123), but the downstream controllers all use [Route("api/[controller]")] and expect paths like /api/Customer/123. For example, CustomerController at src/Services/Customer/Customer.API/Controllers/CustomerController.cs:6 uses [Route("api/[controller]")], but the gateway's customer-route at src/ApiGateway/appsettings.json:18-19 strips /api/customers and forwards just the remainder without adding back a prefix. The same applies to identity, order, and notification routes. If these routes are expected to work, they likely need similar PathPrefix transforms.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good observation — the other routes (identity, customer, order, notification) do have the same structural mismatch. However, this PR is intentionally scoped to the product route only per the task requirements. Fixing the other routes would be a separate task.
Summary
The gateway's
product-routeused onlyPathRemovePrefix: /api/products, which stripped the prefix and forwarded bare paths (/,/123) to the Product service — but the controller is mounted atapi/product, so every request 404'd.Added a
PathPrefix: /api/producttransform after the strip so the rewrite chain becomes:Only
src/ApiGateway/appsettings.jsonwas modified. Build passes; YARP logs confirmProxying to …/api/product.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/bc5a9156cad244339c8ad8d1601e6dc2
Requested by: @mbatchelor81