Panden polygon is not working

Best pdok developers;
At this moment the panden polygon is not working in our website.The error occurred last two weeks ago.Before it was working well. I have not changed any thing on that code but it comes suddenly
Here is the error that i see on the console.
“Access to XMLHttpRequest at ‘https://bag.basisregistraties.overheid.nl/api/v1/verblijfsobjecten/0268010000012268’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.”

I use javascript in the front end and node js in the backend. I use api-key which I have recieved from pdok last year to fetch data from pdok(bag).
Could you help me fixing the error please.
I have tried to fix the cors in my node js server but not succeed.
I think the error come from the blockage of CORS at the server of BAG to our website.
The name of our website is https://www.duurzamedata.nl

Any help please

Could you share the preflight-request that fails? Without it, I have been unable to reproduce your problem.

Of course:
here is the function that i call to

myfunction(verblijfsobjectId){
var id=verblijfsobjectId
axios.get('https://bag.basisregistraties.overheid.nl/api/v1/verblijfsobjecten/’+id,{
headers:{
‘X-Api-Key’:‘my api-key’,
“Accept”: “application/hal+json”
},
}).then(function(response){
console.log(response)
it is not reaching her
})
}

Here the response error that i have got

Access to XMLHttpRequest at ‘https://bag.basisregistraties.overheid.nl/api/v1/verblijfsobjecten/0268010000074078’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.
bag.basisregistraties.overheid.nl/api/v1/verblijfsobjecten/0268010000074078:1 Failed to load resource: net::ERR_FAILED
spread.js:25 Uncaught (in promise) Error: Network Error
at e.exports (spread.js:25)
at XMLHttpRequest.l.onerror (spread.js:25)

Note:I request verblijfobject and panden object from bag.
I can get verblijfobjects without any problem but not panden.
Verblijfobject function is apart from panden function but they have the same structure of code and they use the same api key as well

Thanks inadvance

Hello Gide,

Unfortunately we cannot help you out with the code provided. But when I checked the logging I did see some requests made from localhost:3000/kaartviewer and localhost:3000/guestpage

This way I was able to get a working web example for your website (which might be a non-documented feature?)
From there I did a lookup on my own address and lo and behold, VBO also failed on the same issue.

The problem is not really related to CORS but more the fact that we return a 403 on an OPTIONS call that does not contain an API-key therefor the OPTIONS call fails and a GET is not even tried

image

The problem is that an OPTIONS call will never actually contain an API key as a browser does not know that.

So we have been able to verify your issue which was indeed a bug. We have deployed a fix and now it is working correctly:

image

Yes it is working now, I really appreciate your help guys. thank you so much.

1 like