Open tad0xe opened 2 years ago
i have a nuxt app which i'm using nuxt auth module authentication works fine on my local machine but when deployed on live server authentication doesn't get to work
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 i get a token after signin up
<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); } } } };
nuxt config.js
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" } } } }
error i get after i click login
Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'token' in
everything works fine on my local machine without error both login and signup but when deployed on live server authentication doesn't work
i have a nuxt app which i'm using nuxt auth module authentication works fine on my local machine but when deployed on live server authentication doesn't get to work
my login component
sign up component i get a token after signin up
nuxt config.js
error i get after i click login
everything works fine on my local machine without error both login and signup but when deployed on live server authentication doesn't work