Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Authentication not working with nuxt when deployed on live server

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!