Quarkus, CORS and Missing HTTP Headers

A JAX-RS endpoint:

import java.net.URI;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

public class HelloResource {

        public Response post(String content) {
        var uri = URI.create("/id" + System.currentTimeMillis());
        return Response.created(uri).build();

with activated CORS in application.properties:


...and accessed with browser's fetch from a different domain / port:

const sendPost = async  _ => { 
    const response = await fetch("http://localhost:8080/hello", {
        method: 'POST',
        body:'hello from js'
    const headerContent = response.headers.get('Location');
    console.log('Location header',headerContent);


won't reveal the headers: Location header null.

To access the headers from JavaScript, you will have to list them in Quarkus' configuration:


Since curl is not a browser, the following command: curl -i -XPOST -d'hello' localhost:8080/hello always returns all headers:

HTTP/1.1 201 Created
Content-Length: 0
Location: http://localhost:8080/id1595909973814    

Looks like a bug, but it is actually a feature.


Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments