i have a nuxt app which uses jwt for authentication, on my local machine it works fine but when deployed to a live server the authentication stops working,
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 :
auth: {
strategies: {
local: {
token: {
property: "token",
global: true,
required: true,
type: "Bearer"},
user: {
property: "user",
autoFetch: true
},
endpoints: {
login: {
propertyName: "token",
login: { url: "/api/auth/login", method: "post" },
},
logout: true
},
user: { url: "/api/auth/user", method: "get" }
}
}
}
response i get when i click the login and signup button when deployed on live server
Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'token' in
everything works fine on my local machine but when deploy live to firebase for hosting the authentication stops working