As mentioned above origin was deprecated therefore I used: const origin = req.headers.referer
const origin = req.headers.referer
you should remove the ending slash to make it same as the origin