小编Arj*_*jun的帖子

Laravel 的 Next-Auth 凭证提供程序 - 请求失败,状态代码 419

我有一个安装了 Next-Auth 的 NextJS 前端和一个使用 Sanctum 的 Laravel 后端当我尝试使用 Next-Auth 的登录功能登录时,它给了我这个错误:

Request failed with status code 419
Run Code Online (Sandbox Code Playgroud)

419 与 CSRF 令牌有关,但我在调用登录方法之前通过调用 sainttum/csrf-cookie 路由来设置令牌

[...nextauth.js]

Request failed with status code 419
Run Code Online (Sandbox Code Playgroud)

apiClient.js

CredentialsProvider
        ({
            name: 'Email and Password',
            credentials: {
                email: {label: "Email", type: "email", placeholder: "Your Email"},
                password: {label: "Password", type: "Password"}
            },
            async authorize({email, password}, req) {
                await apiClient.get("/sanctum/csrf-cookie");
                const user = await apiClient.post('/customer/login', {
                    email: email,
                    password: password,
                });

                if (user) {
                    return user
                } else {
                    return …
Run Code Online (Sandbox Code Playgroud)

laravel next.js csrf-token laravel-sanctum next-auth

7
推荐指数
2
解决办法
7703
查看次数

无法在警报框中添加中断

我没有使用"form"标签创建了这种形式

我需要在Hello ____之间的警报框中添加一个中断.您的电子邮件地址是:.是否可以这样做?我试过br标签和\n但似乎什么都没有用

<head>

    <title>Welcome Sheet</title>

</head>

<body>

    <h1> Form Details</h1>
Run Code Online (Sandbox Code Playgroud)

名字

<br>

<input type="text" id="fname" placeholder="eg.John">

<br><br>
Run Code Online (Sandbox Code Playgroud)

<br>

<input type="text" id="lname" placeholder="eg.Doe">

<br><br> 
Run Code Online (Sandbox Code Playgroud)

电子邮件地址

<br>

<input type="email" id="email" placeholder="eg.johndoe@example.com">

<br><br>


    <button onclick="myFunction()">Submit</button>

        <script>

            function myFunction() {
                alert("Hello" + " " + document.getElementById("fname").value+ " " + document.getElementById("lname").value +" "+ "Your email address is:" + " " + document.getElementById("email").value);
                }

        </script>

</body>
Run Code Online (Sandbox Code Playgroud)

html javascript css alert function

0
推荐指数
1
解决办法
58
查看次数