vue.jscorsnuxt.jsnuxt3.js

How to fix CORS error on 3rd party API call in Nuxt 3?


I am working on Nuxt 3 with useFetch hook to call API. When I call the 3rd party API post https://apitest.bankfeeds.com.au/v1/customer/data using useFetch hook, it returns the CORS error

CORS Missing Allow Origin

I have the ssr: false in my nuxt.config.ts file

check error here

I have tried to set cors on nuxt config file but not working and returns the same error.


Solution

  • It's probably giving you a CORS error because you are fetching the API through the browser and not trough the backend.

    Most third party API's deny cross-origin requests.

    Try fetching the API from postman, if it works just put the fetch call in the server-side backend.