Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda