i have a nuxt application with which uses nuxt-auth everything works fine on local host but when deploy on live server i keep getting
Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'token' in
when i click the sign up button i get a token in my console
i cant seem to get the root of the problem everything works fine on my local machine
this is my login component:
<script>
export default {
middleware: "auth",
auth: "guest",
layout: "none",
data() {
return {
email: "",
password: ""
};
},
methods: {
async onLogin() {
try {
this.$auth.loginWith("local", {
data: {
email: this.email,
password: this.password
}
});
this.$router.push("/");
} catch (err) {
console.log(err);
}
}
}
};
</script>
sign up component
<script>
export default {
middleware: "auth",
auth: "guest",
layout: "none",
data() {
return {
name: "",
email: "",
password: ""
};
},
methods: {
async onSignup() {
try {
let data = {
name: this.name,
email: this.email,
password: this.password
};
let response = await this.$axios.$post("api/auth/signup", data);
console.log(response);
if (response.success) {
this.$auth.loginWith("local", {
data: {
email: this.email,
password: this.password
}
});
this.$router.push("/");
}
} catch (err) {
console.log(err);
}
}
}
};
in my nuxt.config.js i have :
const URL =
'https://localhost:5000'
export default {
mode: 'spa',
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'client',
script: [{ src: 'https://js.stripe.com/v3' }],
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' },
{ rel: 'stylesheet', href: '/css/font-awesome/css/all.css' },
{ rel: 'stylesheet', href: '/css/default.css' }
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [{ src: '~/plugins/localStorage.js', mode: 'client' }],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: ['nuxt-compress'],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/bootstrap
'bootstrap-vue/nuxt',
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
// https://go.nuxtjs.dev/pwa
'@nuxtjs/pwa',
'@nuxtjs/auth'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
proxy: true,
baseURL: "https://localhost:5000",
browserBaseURL: "https://localhost:5000",
},
proxy: {
'/api': URL
},
// PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: {
manifest: {
lang: 'en'
}
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
babel: {
compact: true
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
}
},
auth: {
strategies: {
local: {
token: {
property: 'token',
global: true,
// required: true,
// type: 'Bearer'
},
endpoints: {
login: { url: '/api/auth/login', method: 'post', propertyName: "token" },
// logout: { url: '/api/auth/logout', method: 'post' },
user: { url: '/api/auth/user', method: 'get' },
logout: true
},
tokenRequired: true,
tokenType: 'Token',
tokenName: 'Authorization'
}
}
}
}