N
Nuxt2y ago
qb1t

Help with CORS

Hi so I need my website to load resources from an external api on client side Things I tried: using the built-in $fetch() method but I'm getting cors errors using the @nuxtjs/axios module but that doesn't even allow nuxt to start using normal axios and configuring it like this
import axios from 'axios'

const axiosInstance = axios.create({
baseURL: 'http://localhost:3001',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Accept, Content-Type, Authorization'
}
});

export default axiosInstance;
import axios from 'axios'

const axiosInstance = axios.create({
baseURL: 'http://localhost:3001',
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Accept, Content-Type, Authorization'
}
});

export default axiosInstance;
I'm out of ideas what can I do?
2 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
qb1t
qb1tOP2y ago
I didn't setup cors on my api server 🤦‍♂️
Want results from more Discord servers?
Add your server