freeDictionaryAPI icon indicating copy to clipboard operation
freeDictionaryAPI copied to clipboard

CORS Error: Unable to Fetch Data from dictionaryapi.dev

Open ujjalballen opened this issue 1 year ago • 9 comments

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 ...

Image

ujjalballen avatar Oct 17 '25 15:10 ujjalballen

Same here ^

bencoopertx avatar Oct 17 '25 23:10 bencoopertx

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.

ujjalballen avatar Oct 18 '25 05:10 ujjalballen

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?

Smg065 avatar Oct 18 '25 18:10 Smg065

Taking a closer look, the const HEADER_ACCESS_CONTROL_ALLOW_ORIGIN is assigned as Access-Control-Allow-Origin.

freeDictionaryAPI/app.js

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,

freeDictionaryAPI/app.js

Line 60 in 4f274a8

this.set(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, '*'); And one when the API tries to get the word.

freeDictionaryAPI/app.js

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.

ujjalballen avatar Oct 19 '25 08:10 ujjalballen

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.

Smg065 avatar Oct 21 '25 00:10 Smg065

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.

meetDeveloper avatar Oct 21 '25 05:10 meetDeveloper

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.

Image

sgbeal avatar Aug 11 '26 17:08 sgbeal

@sgbeal same here, unfortunately...

comaeclipse avatar Aug 18 '26 14:08 comaeclipse

I'm also having this issue, but I get this error 100% of the time.

adriennvarn avatar Aug 20 '26 17:08 adriennvarn