diff --git a/app/router.scrollBehavior.js b/app/router.scrollBehavior.js new file mode 100644 index 000000000..d70bb5021 --- /dev/null +++ b/app/router.scrollBehavior.js @@ -0,0 +1,3 @@ +export default function (to, from, savedPosition) { + return savedPosition || { x: 0, y: 0 } +} diff --git a/layouts/default.vue b/layouts/default.vue index 4246c56bc..d986b0b6d 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -199,7 +199,7 @@ export default { }, computed: { authUrl() { - return `https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${this.$route.fullPath}` + return `${this.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${this.$route.fullPath}` }, userUrl() { return `/user/${this.$auth.user.id}` diff --git a/layouts/error.vue b/layouts/error.vue index 00e238b82..fcc7b0bcf 100644 --- a/layouts/error.vue +++ b/layouts/error.vue @@ -31,9 +31,6 @@ export default { }, }, layout: 'home', - created() { - // console.log(this.error) - }, } diff --git a/middleware/analytics.js b/middleware/analytics.js index 1a2aa8fd5..4d86c7193 100644 --- a/middleware/analytics.js +++ b/middleware/analytics.js @@ -1,5 +1,8 @@ import axios from 'axios' -export default async function (context) { +export default function (context) { + if (context.$config.analytics.base_url == null) { + return + } let domain = '' if (process.server) { domain = context.req.headers.host @@ -8,13 +11,16 @@ export default async function (context) { } const url = context.$config.analytics.base_url + '/register/visit' const path = context.route.path.split('?')[0] - try { - return await axios.post(url, { - path, - domain, - consent: false, - }) - } catch (e) { - // Simply silence the issue. - } + setTimeout(() => { + axios + .post(url, { + path, + domain, + consent: false, + }) + .then(() => {}) + .catch((e) => { + console.error('An error occurred while registering the visit: ', e) + }) + }) } diff --git a/middleware/auth.js b/middleware/auth.js index f1db0f50a..12c3e8f16 100644 --- a/middleware/auth.js +++ b/middleware/auth.js @@ -37,7 +37,7 @@ export default async function (context) { if (!context.$auth.user) { return context.redirect( - `https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${context.route.fullPath}` + `${context.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${context.route.fullPath}` ) } } diff --git a/nuxt.config.js b/nuxt.config.js index 6af80c1b7..07717e169 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -134,6 +134,7 @@ export default { ** See https://axios.nuxtjs.org/options */ axios: { + baseURL: 'https://api.modrinth.com/api/v1/', headers: { common: { Accept: 'application/json', diff --git a/pages/dashboard.vue b/pages/dashboard.vue index d4234dfa5..fef49e81b 100644 --- a/pages/dashboard.vue +++ b/pages/dashboard.vue @@ -81,7 +81,7 @@ export default { }, computed: { authUrl() { - return `https://api.modrinth.com/api/v1/auth/init?url=${process.env.domain}${this.$route.fullPath}` + return `${this.$axios.defaults.baseURL}auth/init?url=${process.env.domain}${this.$route.fullPath}` }, }, } diff --git a/pages/dashboard/follows.vue b/pages/dashboard/follows.vue index efdcd4d9e..799fe18d4 100644 --- a/pages/dashboard/follows.vue +++ b/pages/dashboard/follows.vue @@ -46,8 +46,6 @@