API returns "error": "Access to this API has been disallowed" #96

Dear ORS Team,
i am trying to use the openrouteservice-js in simple sketch project.
But I am having trouble, while my API Key works in your API playground website.
Import via import Openrouteservice from 'https://cdn.jsdelivr.net/npm/openrouteservice-js@latest/dist/ors-js-client.js';
then using the example script.

The api response is {“error”: “Access to this API has been disallowed”}

async function test() {
    const Isochrones = new Openrouteservice.Isochrones({ 
        api_key: "my_key_xyz"
    });
    try {
        let response = await Isochrones.calculate({
            locations: [[8.690958, 49.404662], [8.687868, 49.390139]],
            profile: 'foot-walking',
            range: [1],
            units: 'km',
            range_type: 'distance',
            attributes: ['area'],
            area_units: 'km'
        })
        // Add your own result handling here
        console.log("response: ", response)

    } catch (err) {
        console.log("An error occurred: " + err)
        console.error(await err.response.json())
    }
}

The browser shows a CORS issue , while the OPTIONS request goes through.

Can you point me into the right direction to fix this?

Hey,

depending on your timing, that might have clashed with our maintenance yesterday.
Regarding CORS in general, have a look through the forum, there’s quite a few posts that talk about it.

Best regards

1 Like

Thank you for your quick answer!
It does work now!

2 Likes