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

161
Views
Problem with API and Fiddler: Login API only works when Fiddler is running: Laravel/Vue

I have a login API as seen below:

api.php

Route::post('/login', [LoginController::class, 'login']);

LoginController.php

public function login(Request $request) {
        $fields = $request->validate([
            'email' => 'required|string',
            'password' => 'required|string'
        ]);

        // Check email
        $user = User::where('email', $fields['email'])->first();

        // Check password
        if(!$user || !Hash::check($fields['password'], $user->password)) {
            return response([
                'message' => 'Bad creds'
            ], 401);
        }

        $token = $user->createToken('myapptoken')->plainTextToken;

        $response = [
            'user' => $user,
            'token' => $token
        ];

        return response($response, 201);
    }

I call this API from my Vue.js frontend component:

Script in Login.Vue

<script>
export default {
  name: 'Login',

  data() {
    return {
      user: {
        email: null,
        password: null
      },
      loading: false,
      error: null
    }
  },

  methods: {
    async login() {
      this.error = null;
      try {
        await this.$store.dispatch('login', this.user);
        await this.$router.push({ name: 'posts' });

      } catch (error) {
        this.error = error;
      } 
      finally {
        this.loading = false;
      }
    }
  }
}
</script>

store/index.js

async login({ commit }, user) {
          await repository.createSession();
          const { data } = await repository.login(user);
          commit('SET_USER', data);
          sessionStorage.user = JSON.stringify(data);
          sessionStorage.user_token = data.token;
        }

The problem is that it works only when Fiddler is also running. Without Fiddler, i dont get any errors, but i also cannot login. What could be wrong?

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!