Vue, Nuxt | Axios-запрос блокируется CORS
Пытаюсь отправить запрос при создании компонента через хранилище, т.е.
beforeCreate() {
this.$store.dispatch('shops/list');
}
Код хранилища:
export const actions = {
async list(state, data={}) {
await this.$axios.get('http://5.181.109.52/api/shop').then((response) => {
state.commit('setShops', response.data.shops.data)
});
}}
Но получаю ошибку
Access to XMLHttpRequest at 'http://5.181.109.52/api/shop' from origin 'http://localhost:32123' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Nuxt Config:
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
server: {
port: 32123, // default: 3000
},
head: {
title: 'booster',
htmlAttrs: {
lang: 'en'
},
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
{ name: 'format-detection', content: 'telephone=no' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
},
axios:{
proxy: true
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'@/assets/css/commons.css'
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [{ src: '@/plugins/VueAwesomeSwiper.js' },],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxtjs/axios',
'@nuxtjs/auth-next'],
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {}
}