CodexBloom - Programming Q&A Platform

OCI API Gateway Not Forwarding Headers to Backend Service When Using Java SDK

👀 Views: 25 đŸ’Ŧ Answers: 1 📅 Created: 2025-08-20
oci api-gateway java-sdk Java

I'm currently integrating an OCI API Gateway with a backend service using the Java SDK, but I'm working with an scenario where the custom headers I expect to be forwarded to my backend service are missing. I have set up my API Gateway with a simple configuration, but when I make requests, the backend only receives the default headers and not the custom ones. Here's a snippet of my API Gateway configuration where I set the custom headers: ```json { "backend": { "uri": "https://my-backend.service.com", "headers": { "X-Custom-Header": "MyValue" } }, "routes": [ { "path": "/api/*", "methods": ["GET", "POST"], "backend": "my-backend" } ] } ``` In my Java SDK client code, I am making the following request: ```java HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://my-api-gateway.service.com/api/test")) .header("X-Custom-Header", "MyValue") .GET() .build(); client.send(request, HttpResponse.BodyHandlers.ofString()); ``` When I log the incoming request on the backend, it does not show the `X-Custom-Header`. I've double-checked the API Gateway policies, and it seems like everything is configured correctly. Additionally, I've verified that my backend service is capable of handling these headers, and it works as expected when I bypass the API Gateway and call the backend directly. I've tried to enable logging on the API Gateway to see if there is any indication of a dropped header, but the logs don't provide much insight. I also experimented with different header formats and ensured that they follow the HTTP/2 specifications, as my backend accepts HTTP/2 requests. Does anyone have experience with this scenario or suggestions on what could be going wrong? Are there any additional configurations I might be missing in the OCI API Gateway setup that could cause this behavior?