简体   繁体   中英

Laravel API: Postman Login Request Returning HTML page

i really don't know how to put the question, but its a laravel api development issue i am facing,

When i send Login request for the first time in my laravel api, sure, i get a successful response on postman

    "success": true,
    "message": "Login successful",
    "data": {
        "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC90b2RvZXIudGVzdFwvYXBpXC9sb2dpbiIsImlhdCI6MTYxNTUyOTEzOCwiZXhwIjoxNjE1NTMyNzM4LCJuYmYiOjE2MTU1MjkxMzgsImp0aSI6IkJBejkydEI2RmVIeThTNEwiLCJzdWIiOjEsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.KKuNrfenfysbz3qtkYrX8-kkBv8l5BPImnqAsPu2XMU",
        "token_type": "bearer",
        "expires_in": 1615532738
    }

so just for testing sake, i send the login Request again even though i still have a valid token, now my problem is what i get back as response. i get back the default laravel blade home page as response.

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="WfxbjFZRMsFBcFTaSGyDSD2BUfdMtcbRjs62umly">

    <title>Todoer</title>

    <!-- Scripts -->
    <script src="http://todoer.test/js/app.js" defer></script>

    <!-- Fonts -->
    <link rel="dns-prefetch" href="//fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">

    <!-- Styles -->
    <link href="http://todoer.test/css/app.css" rel="stylesheet">
</head>

<body>
    <div id="app">
        <nav class="navbar navbar-expand-md navbar-light bg-white shadow-sm">
            <div class="container">
                <a class="navbar-brand" href="http://todoer.test">
                    Todoer
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav mr-auto">

                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <!-- Authentication Links -->
                        <li class="nav-item dropdown">
                            <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button"
                                data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                tochukwu
                            </a>

                            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
                                <a class="dropdown-item" href="http://todoer.test/logout" onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                    Logout
                                </a>

                                <form id="logout-form" action="http://todoer.test/logout" method="POST" class="d-none">
                                    <input type="hidden" name="_token" value="WfxbjFZRMsFBcFTaSGyDSD2BUfdMtcbRjs62umly">                                    </form>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-md-8">
                        <div class="card">
                            <div class="card-header">Dashboard</div>

                            <div class="card-body">

                                You are logged in!
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>
</body>

</html>

So what i really wanna know is if this is going to cause any problem in the client area. I hope this is understandable.

Ok, i found a solution and i guess this was just a postman issue, i just changed the authorization Type from bearer-token to No-Auth在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM