CORS Error: Unable to Fetch Data from dictionaryapi.dev
When fetching data from the https://api.dictionaryapi.dev/api/v2/entries/en/ "word" endpoint, the request is being blocked by the browser due to a CORS policy error. Previously, this API worked without any CORS issues, but it recently started showing the following message in the browser console.
In addition to the CORS error, the API sometimes returns a 522 status code at random, especially for words that do not exist in the dictionaryapi or when an invalid/wrong word is send ...
Same here ^
Same here ^
Is it going to be fixed soon, mate, or will it stay like that? I'm not sure! It’s had this issue for a long time and still hasn’t been fixed.
Taking a closer look, the const HEADER_ACCESS_CONTROL_ALLOW_ORIGIN is assigned as Access-Control-Allow-Origin. https://github.com/meetDeveloper/freeDictionaryAPI/blob/4f274a853dd7a352aa2a349d1b92624ff18a36a8/app.js#L32
Here's the 2 spaces it's set as a wild card, one during error handling, https://github.com/meetDeveloper/freeDictionaryAPI/blob/4f274a853dd7a352aa2a349d1b92624ff18a36a8/app.js#L60
And one when the API tries to get the word. https://github.com/meetDeveloper/freeDictionaryAPI/blob/4f274a853dd7a352aa2a349d1b92624ff18a36a8/app.js#L114
In theory, that should be passing it correctly, but I think something's interrupting it before it gets to that line. We could confirm if someone was self-hosting this and it can still pull correctly.
The 522 error from Cloudfare comes from a timeout. The 19 second SYN+ACK never received before, rather than the resource request from 90 seconds. You can count that one out by going to a random word.
I haven't found a word that doesn't return a 522 yet from my own testing. Is it random on a per-word basis, or will it arbitrarily work and stop working with the same word attempted?
Taking a closer look, the const HEADER_ACCESS_CONTROL_ALLOW_ORIGIN is assigned as Access-Control-Allow-Origin.
Line 32 in 4f274a8
HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = 'Access-Control-Allow-Origin'; Here's the 2 spaces it's set as a wild card, one during error handling,
Line 60 in 4f274a8
this.set(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, '*'); And one when the API tries to get the word.
Line 114 in 4f274a8
res.set(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, '*'); In theory, that should be passing it correctly, but I think something's interrupting it before it gets to that line. We could confirm if someone was self-hosting this and it can still pull correctly.
The 522 error from Cloudfare comes from a timeout. The 19 second SYN+ACK never received before, rather than the resource request from 90 seconds. You can count that one out by going to a random word.
I haven't found a word that doesn't return a 522 yet from my own testing. Is it random on a per-word basis, or will it arbitrarily work and stop working with the same word attempted?
Thanks for the detailed breakdown, really appreciate it! I also think it could be getting interrupted before it reaches that line, but I’m not sure.
And your explanation about the 522 timeout and the missing SYN+ACK makes sense. From my side, it doesn’t seem tied to any specific word. However, today it’s consistently returning a 522 “Connection timed out” error for every request, regardless of the word. But after a few minutes, it works, although some words (like 'dictionary,' 'more,' 'fetch,' etc.) are not included in the Dictionary API. At those times, it returns a 522 error from Cloudflare.
So it looks more like an intermittent issue with the public API or Cloudflare setup rather than the request itself.
https://freedictionaryapi.com/ The V1 version seems to still be working, unless there's another Wiktionary-based API that has /VX/ in the URL structurally that started with the whole dictionary and then moved over to only the English one.
This should be working now. Sorry for the inconvenience. I will try to improve availability of the API so that such problems never occur. Thank you for using this API.
i get this on a full half of my requests. This screenshots shows debug entries for when words are clicked in my app. The ones with no error after them worked, the others failed. Sometimes it's a 404, which is fine, but the CORS errors are random, almost as if half of the servers serving that endpoint are misconfigured.
@sgbeal same here, unfortunately...
I'm also having this issue, but I get this error 100% of the time.