我在 Azure VM 上安裝了 Strapi。嘗試連接到 /api/connect/microsoft 端點以使用活動目錄進行授權。一切都在本地作業,但在服務器上它不斷給我一個 500 內部服務器錯誤。Azure vm 上的 Strapi 是使用 nginx 設定的。
這是我們在日志中發現的
1|strapi-prod | [2022-02-18 22:59:00.277] http: GET /api/connect/microsoft (60 ms) 302
1|strapi-prod | Error: Cannot send secure cookie over unencrypted connection
1|strapi-prod | at Cookies.set (/srv/strapi/strapi/node_modules/cookies/index.js:94:11)
1|strapi-prod | at ContextSession.save (/srv/strapi/strapi/node_modules/koa-session/lib/context.js:339:22)
1|strapi-prod | at ContextSession.commit (/srv/strapi/strapi/node_modules/koa-session/lib/context.js:239:16)
1|strapi-prod | at session (/srv/strapi/strapi/node_modules/koa-session/index.js:46:20)
1|strapi-prod | at async /srv/strapi/strapi/node_modules/@strapi/strapi/lib/services/metrics/middleware.js:29:5
任何幫助表示贊賞!
uj5u.com熱心網友回復:
我沒有使用 Stapi,但答案在錯誤訊息中:
錯誤:無法通過未加密的連接發送安全 cookie
這意味著在不使用 https 的情況下,在您的 cookie 配置中您應該:
安全:假
例子:
{
...
httpOnly: true,
maxAge: 24*60*60*1000,
secure: false // if true only send cookie over https
...
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/428581.html
