import axios from "axios"; export default { // Global page headers: https://go.nuxtjs.dev/config-head head: { htmlAttrs: { lang: 'ru' }, title: 'amic.ru', meta: [ { name: 'viewport', content: 'width=device-width, initial-scale=1' } ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, ], script: [ ], }, plugins: [ {} ], // Global CSS: https://go.nuxtjs.dev/config-css css: [ "@/assets/styles/style.less" ], ssr: true, crossorigin: 'anonymous', // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins plugins: [ '~plugins/vue-alert.js', '~plugins/axios.js', '~plugins/vue-js-modal.js', '~plugins/v-clipboard.js', '~plugins/timeago.js', '~plugins/dropdown.js', '~plugins/vuelidate.js', '~plugins/paginate.js', '~plugins/vue-cookies.js', '~plugins/jsonld.js', ], // Auto import components: https://go.nuxtjs.dev/config-components components: true, // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules // Modules: https://go.nuxtjs.dev/config-modules modules: [ '@nuxtjs/style-resources', // https://go.nuxtjs.dev/axios '@nuxtjs/axios', '@nuxtjs/proxy', // https://go.nuxtjs.dev/pwa '@nuxtjs/pwa', '@nuxtjs/amp', '@nuxtjs/auth-next', 'vue-social-sharing/nuxt', '@nuxtjs/redirect-module', ], redirect: [ { from: '/news/(\\d+)', to: async (from, req) => { const regex = new RegExp(from); const id = regex.exec(req.url)[1]; const news = await axios .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`) .then((res) => res.data.data) .catch(() => null) if(!news) return '/news'; return `/news/${news.category.alias}/${news.alias}`; }, statusCode: 301 }, { from: '/podcasts/(\\d+)', to: async (from, req) => { const regex = new RegExp(from); const id = regex.exec(req.url)[1]; const news = await axios .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`) .then((res) => res.data.data) .catch(() => null) if(!news) return '/news'; return `/podcasts/${news.alias}`; }, statusCode: 301 }, { from: '/voprosdnya/(\\d+)', to: async (from, req) => { const regex = new RegExp(from); const id = regex.exec(req.url)[1]; const news = await axios .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`) .then((res) => res.data.data) .catch(() => null) if(!news) return '/news/voprosdnya'; return `/news/voprosdnya/${news.alias}`; }, statusCode: 301 }, ], styleResources: { less: [] }, privateRuntimeConfig: { apiUrl: process.env.API_URL }, // Axios module configuration: https://go.nuxtjs.dev/config-axios axios: { proxy: true, prefix: "https://api.amic.ru/api/v1", headers: { } }, proxy: { '/api/': { target: 'https://api.amic.ru/api/v1', pathRewrite: { '^/api/': '' } } }, // PWA module configuration: https://go.nuxtjs.dev/pwa pwa: { manifest: { lang: 'ru' } }, amp: { amp: true, css: '@/assets/css/amp.css', routeAliases: ['/news/:category/:alias'] }, colorMode: { preference: 'light' }, router: { }, auth: { plugins: [ {src: '~/plugins/axios', ssr: true}, '~/plugins/auth.js' ], redirect: { login: '/user/authorization', logout: '/', callback: '/login', home: '/' }, strategies: { local: { token: { property: "data.access_token", name: "AccessToken", type: false, maxAge: 3240000, global: true, }, user: { property: "data", }, endpoints: { login: { url: "/user/authorization/login", method: "post" }, user: { url: "/authorized/user/profile/info/current", method: "get", propertyName: "data" }, logout: { url: "authorized/user/authorization/logout", method: "post" } } } } }, // Build Configuration: https://go.nuxtjs.dev/config-build build: { extend(config) { config.resolve.alias.vue = 'vue/dist/vue.common' }, }, render: { compressor: false }, buildModules: [ '@nuxtjs/pwa', '@nuxtjs/vuetify', '@nuxt/typescript-build', '@nuxtjs/color-mode', '@nuxtjs/device' ] }