When using Quarkus and considering using it to deploy lambda functions to AWS.
I’ve been able to create a function with GET and POST endpoints, link them to the API Gateway and hit them from Postman.
However, I’m running into a CORS error when I test it out in a React app.
I’ve enabled a CORS on the API gateway resource, and logs show that the request gets to the lambda, and returns my payload to the API gateway, but still fails due to the CORS.
I understand that for proxy integration with lambda, I need to pass the CORS headers in the response payload in addition to enabling CORS on the API gateway.
So with the Quarkus, how do I achieve this?
I’ve tried to set these in the application.properties
file, but that doesn’t do anything.
Would appreciate some help with this.
quarkus.http.cors=true
quarkus.http.cors.origins=*
quarkus.http.cors.methods=GET,PUT,POST
quarkus.http.cors.headers=x-api-key, accept, authorization, content-type
quarkus.http.cors.access-control-allow-credentials=true
Resource
@Path("/hello")
public class GreetingResource {
@GET
@Produces("application/json")
public String hello() {
return """
{
"msg": "hello"
}
""";
}
}