首页 > 解决方案 > 如果我将我的应用程序重定向到 Next JS 页面,我们可以提取 Next JS 页面中的标题吗?

问题描述

我正在研究 intuit-oauth 并意识到我不能对我的 'api/auth/qb' 执行 axios.get ,它将我重定向到在后端生成链接的授权页面。它引发了 CORS 错误,并且 intuit 团队在论坛中表示他们不支持客户端 oauth(https://help.developer.intuit.com/s/question/0D50f00005pP1e5/cors-error-while-getting -access-token-using-url-httpsoauthplatformintuitcomoauth2v1tokensbearer),因此出现错误。

错误:

Access to XMLHttpRequest at 'https://appcenter.intuit.com/connect/oauth2?client_id=<MY_CLIENT_ID>&redirect_uri=<MY_REDIRECT_URI>&response_type=code&scope=com.intuit.quickbooks.accounting%20openid&state=<MY_STATUS>' (redirected from 'http://localhost:3000/api/auth/qb') from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

the next js pages structure:

pages
--index.tsx
--dashboard.tsx
--api
   |--auth
       |--qb.tsx

因此,我计划在获得访问令牌并在标头中发送访问令牌后,将用户从后端重定向到“/dashboard”,然后如果我可以在 nextJS 页面中提取代码,我会将其存储在local storage,所以问题是:我可以在下一个 js 页面上提取它吗?如果可以,如何提取?

标签: javascriptreactjsoauthnext.jsintuit

解决方案


推荐阅读