Status 406 - "not acceptable"

Hi,

I am developing an WebApp that should downloads directions from openrouteservice. While doing this, I am running into a CORS-Issue that I can’t fix myself.

I do have a custom deployment of ors on my own server (6.1.0), but either my own deployment, nor api.openrouteservice.org wouldn’t give me any other response then this:

{
body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 406
statusText: "Not Acceptable"
type: "cors"
url: "https://api.openrouteservice.org/v2/directions/driving-car?api_key=xxx&start=7.429504967636316,51.51331787611618&end=7.427511500153572,51.517601389205424"
}

What can I do to have a more willingly serving server?

If I call the url manually (and not from my locally (with parcel) hosted App) I get a response I can work with.

Please be aware, when you take your time to answer: I am not a trained developer but an urban planner doing some programming… (and am not really sure if I understand CORS at all…).

Kind regards + thank you! Janne

Hey,

without further review, just b/c “CORS” was mentioned - have a look at the last two comments in this thread, that might help.

Best regards

I think my web.xml ist correct (it is the default, deployed by docker-compose PLUS added “Authorization”)

    <filter>
                <filter-name>CorsFilter</filter-name>
                <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
                <init-param>
                        <param-name>cors.allowed.origins</param-name>
                        <param-value>*</param-value>
                </init-param>
                <init-param>
                        <param-name>cors.allowed.methods</param-name>
                        <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
                </init-param>
                <init-param>
                        <param-name>cors.allowed.headers</param-name>
                        <param-value>Authorization,Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
                </init-param>
                <init-param>
                        <param-name>cors.exposed.headers</param-name>
                        <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
                </init-param>
                <init-param>
                        <param-name>cors.support.credentials</param-name>
                        <param-value>false</param-value>
                </init-param>
                <init-param>
                        <param-name>cors.preflight.maxage</param-name>
                        <param-value>10</param-value>
                </init-param>
        </filter>

        <filter-mapping>
                <filter-name>CorsFilter</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>

Any other ideas? Is it possible I call it wrong from my webapp?

And just to make it more clear: openrouteservice ist deployed on a server. The development happens on localhost.

Ah, I am sorry. I sent the wrong header ’ accept: “application/json” ’ - Now it works.

2 Likes