Search code examples
restauthenticationaxiosbpmncamunda

Camunda 403 error when rest-api request sent from ui


I'm trying out Camunda with authentication filter. The same request works fine with basic auth from postman, but when i send it from the UI I get 403 error for the OPTIONS request and the POST request fails. PS: I have my cors filter set up, it works fine if I disable the authentication filter. This is the request in postman enter image description here

and this is the request in my code

await axios.post(`${process.env.REACT_APP_API}/process-definition/key/${process.env.REACT_APP_PROCESS}/start`, {}, {
            headers: { 'Authorization': 
                {username: "demo",
                password: "demo"}
            }
        })

I tried also this syntax:

await axios.post(`${process.env.REACT_APP_API}/process-definition/key/${process.env.REACT_APP_PROCESS}/start`, {}, {
            auth: 
                {username: "demo",
                password: "demo"}
        })

Solution

  • As mentionned in this post its a problem with cors.allowed.headers in the web.xml file. I added Authorization in the filter and no more 403 error:

    <init-param>
                <param-name>cors.allowed.headers</param-name>
                <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization</param-value>
    </init-param>