Search code examples
ethereumquorum

Tessera Cross Origin Issues while calling the rest API ( /storeraw )


I am using tessera for execute private transaction's in Quorum. When invoking the third party (privateURL) API from the postman, I am getting the expected output but when calling the same API's from the other server I am getting an empty response with 200 status code( http://:9081/storeraw). This issue is happening due to the CORS. I've checked with:

File:///< HTML_PATH >

and it's working.

How to enable CORS for tessera third party API's?


Solution

  • Currently, this feature is not implemented in tessera. I'm working already I'll get back to you once it's done. For enabling CORS follow steps below.

    1. Clone repository from git.
    2. open the file /jaxrs-service/src/main/java/com/quorum/tessera/thridparty/RawTransactionResource.java
    3. Replace

    return Response.status(Status.OK) .type(APPLICATION_JSON) .entity(response) .build();

    with

    return Response.status(Status.OK)
    .type(APPLICATION_JSON)
    .header("Access-Control-Allow-Origin", "*")
    .entity(response)
    .build();
    
    1. Recompile the code
    2. Start tessera.

    Note: This will allow all origins, please modify the code as per your security needs. This is not a standard, I am working on config changes that will allow you to have the freedom to enable CORS with corresponding changes.