nuxt.config.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import axios from "axios";
  2. export default {
  3. // Global page headers: https://go.nuxtjs.dev/config-head
  4. head: {
  5. htmlAttrs: {
  6. lang: 'ru'
  7. },
  8. title: 'amic.ru',
  9. meta: [
  10. { name: 'viewport', content: 'width=device-width, initial-scale=1' }
  11. ],
  12. link: [
  13. { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
  14. ],
  15. script: [
  16. ],
  17. },
  18. plugins: [
  19. {}
  20. ],
  21. // Global CSS: https://go.nuxtjs.dev/config-css
  22. css: [
  23. "@/assets/styles/style.less"
  24. ],
  25. ssr: true,
  26. crossorigin: 'anonymous',
  27. // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  28. plugins: [
  29. '~plugins/vue-alert.js',
  30. '~plugins/axios.js',
  31. '~plugins/vue-js-modal.js',
  32. '~plugins/v-clipboard.js',
  33. '~plugins/timeago.js',
  34. '~plugins/dropdown.js',
  35. '~plugins/vuelidate.js',
  36. '~plugins/paginate.js',
  37. '~plugins/vue-cookies.js',
  38. '~plugins/jsonld.js',
  39. ],
  40. // Auto import components: https://go.nuxtjs.dev/config-components
  41. components: true,
  42. // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  43. // Modules: https://go.nuxtjs.dev/config-modules
  44. modules: [
  45. '@nuxtjs/style-resources',
  46. // https://go.nuxtjs.dev/axios
  47. '@nuxtjs/axios',
  48. '@nuxtjs/proxy',
  49. // https://go.nuxtjs.dev/pwa
  50. '@nuxtjs/pwa',
  51. '@nuxtjs/amp',
  52. '@nuxtjs/auth-next',
  53. 'vue-social-sharing/nuxt',
  54. '@nuxtjs/redirect-module',
  55. ],
  56. redirect: [
  57. {
  58. from: '/news/(\\d+)',
  59. to: async (from, req) => {
  60. const regex = new RegExp(from);
  61. const id = regex.exec(req.url)[1];
  62. const news = await axios
  63. .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`)
  64. .then((res) => res.data.data)
  65. .catch(() => null)
  66. if(!news) return '/news';
  67. return `/news/${news.category.alias}/${news.alias}`;
  68. },
  69. statusCode: 301
  70. },
  71. {
  72. from: '/podcasts/(\\d+)',
  73. to: async (from, req) => {
  74. const regex = new RegExp(from);
  75. const id = regex.exec(req.url)[1];
  76. const news = await axios
  77. .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`)
  78. .then((res) => res.data.data)
  79. .catch(() => null)
  80. if(!news) return '/news';
  81. return `/podcasts/${news.alias}`;
  82. },
  83. statusCode: 301
  84. },
  85. {
  86. from: '/voprosdnya/(\\d+)',
  87. to: async (from, req) => {
  88. const regex = new RegExp(from);
  89. const id = regex.exec(req.url)[1];
  90. const news = await axios
  91. .get(`https://api.amic.ru/api/v1/news/item/old_id_${id}`)
  92. .then((res) => res.data.data)
  93. .catch(() => null)
  94. if(!news) return '/news/voprosdnya';
  95. return `/news/voprosdnya/${news.alias}`;
  96. },
  97. statusCode: 301
  98. },
  99. ],
  100. styleResources: {
  101. less: []
  102. },
  103. privateRuntimeConfig: {
  104. apiUrl: process.env.API_URL
  105. },
  106. // Axios module configuration: https://go.nuxtjs.dev/config-axios
  107. axios: {
  108. proxy: true,
  109. prefix: "https://api.amic.ru/api/v1",
  110. headers: {
  111. }
  112. },
  113. proxy: {
  114. '/api/': { target: 'https://api.amic.ru/api/v1', pathRewrite: { '^/api/': '' } }
  115. },
  116. // PWA module configuration: https://go.nuxtjs.dev/pwa
  117. pwa: {
  118. manifest: {
  119. lang: 'ru'
  120. }
  121. },
  122. amp: {
  123. amp: true,
  124. css: '@/assets/css/amp.css',
  125. routeAliases: ['/news/:category/:alias']
  126. },
  127. colorMode: {
  128. preference: 'light'
  129. },
  130. router: {
  131. },
  132. auth: {
  133. plugins: [ {src: '~/plugins/axios', ssr: true}, '~/plugins/auth.js' ],
  134. redirect: {
  135. login: '/user/authorization',
  136. logout: '/',
  137. callback: '/login',
  138. home: '/'
  139. },
  140. strategies: {
  141. local: {
  142. token: {
  143. property: "data.access_token",
  144. name: "AccessToken",
  145. type: false,
  146. maxAge: 3240000,
  147. global: true,
  148. },
  149. user: {
  150. property: "data",
  151. },
  152. endpoints: {
  153. login: {
  154. url: "/user/authorization/login",
  155. method: "post"
  156. },
  157. user: {
  158. url: "/authorized/user/profile/info/current",
  159. method: "get",
  160. propertyName: "data"
  161. },
  162. logout: {
  163. url: "authorized/user/authorization/logout",
  164. method: "post"
  165. }
  166. }
  167. }
  168. }
  169. },
  170. // Build Configuration: https://go.nuxtjs.dev/config-build
  171. build: {
  172. extend(config) {
  173. config.resolve.alias.vue = 'vue/dist/vue.common'
  174. },
  175. },
  176. render: {
  177. compressor: false
  178. },
  179. buildModules: [
  180. '@nuxtjs/pwa',
  181. '@nuxtjs/vuetify',
  182. '@nuxt/typescript-build',
  183. '@nuxtjs/color-mode',
  184. '@nuxtjs/device'
  185. ]
  186. }