JWT 和 Next JS 调用问题

时间:2021-03-26 00:07:51

标签: javascript jwt next.js fetch-api

使用 Insomnia,我使用 JWT 调用 api。

enter image description here

我想用 Next.js 做同样的事情。

async function getServerSideProps() {
    // Fetch data from external API
    const res = await fetch(
        `http://XXXXXXonesystems.io/oauth/token?response_type=code
                            &client_id=12
                            &secret=HdDxxxxxxxxxxxxxxxxxxxxxxxx6kn
                            &redirect_uri=https://xxxxxxx.bonesystems.io/api/workflow                           
                            &state=abcde`,
        {
            crossDomain: true,
            method: "GET", // *GET, POST, PUT, DELETE, etc.
            mode: "no-cors", // no-cors, *cors, same-origin
            cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
            credentials: "same-origin", // include, *same-origin, omit
            headers: {
                "Content-Type": "application/json",
                "Access-Control-Allow-Origin": "http://localhost:3000",
                // 'Content-Type': 'application/x-www-form-urlencoded',
            },
            redirect: "follow", // manual, *follow, error
            referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
        }
    );
    console.log("RESPUESTA", res);

    // ...
}

但是浏览器检查器上的响应是“不透明的”,不知道是什么意思。

enter image description here

检查控制台让我认为错误可能出在方法或 fetch 调用的选项中,但我是 JWT 的新手,不知道如何解决。

enter image description here

0 个答案:

没有答案