NEXT-AUTH-500/api/AUTH/signin上的内部服务器错误,无法访问实时网站上的登录页面



我到处找,但没有发现任何与我的案子有关的东西。

我在next.js应用程序上使用nexttauth进行简单登录,以管理网站上的内容。

自从我在数字海洋上的ubuntu 20.04液滴中配置了nginx以来,当我试图访问/api/auth/signin页面时,我收到了500个内部服务器错误

以下是我尝试访问登录页面后的下一个身份验证日志-需要明确的是,出于隐私原因,示例是占位符:

[next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error invalid json response body at https://EXAMPLE.com/api/auth/session reason: Unexpected token I in JSON at position 0 { error:
{ message:
'invalid json response body at https://EXAMPLE.com/api/auth/session reason: Unexpected token I in JSON at position 0',
stack:
'FetchError: invalid json response body at https://EXAMPLE.com/api/auth/session reason: Unexpected token I in JSON at position 0n    at /var/www/EXAMPLE.com/node_modules/node-fetch/lib/index.js:272:32n    at process._tickCallback (internal/process/next_tick.js:68:7)',
name: 'FetchError' },
path: 'session',
header:
{ 'x-real-ip': '5.28.71.45',
'x-forwarded-for': '5.28.71.45',
'x-nginx-proxy': 'true',
host: 'EXAMPLE.com',
connection: 'close',
'sec-ch-ua':
'" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'upgrade-insecure-requests': '1',
'user-agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36',
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
purpose: 'prefetch',
'sec-fetch-site': 'none',
'sec-fetch-mode': 'navigate',
'sec-fetch-user': '?1',
'sec-fetch-dest': 'document',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9,de;q=0.8,he;q=0.7' },
message:
'invalid json response body at https://EXAMPLE.com/api/auth/session reason: Unexpected token I in JSON at position 0' }
/var/www/EXAMPLE.com/node_modules/openid-client/lib/issuer.js:32
#metadata;
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/var/www/EXAMPLE.com/node_modules/openid-client/lib/index.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)

我猜位置0中的意外i可能是内部服务器错误中的i

我很确定这与nginx配置有关,因为当我第一次在没有ngnix的情况下设置项目时,一切都很好——我能够毫无问题地访问/api/auth/sigin页面。当谈到ngnix时,我完全是个傻瓜,所以我很可能错过了我需要做的事情。

在/etc/nginx/站点启用/默认:

server {
listen 80 default_server;
listen [::]:80 default_server;
return 301 https://$host$request_uri;
}
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name EXAMPLE.com;
# Use the Let’s Encrypt certificates
ssl_certificate /etc/letsencrypt/live/EXAMPLE.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/EXAMPLE.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:8080/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}

任何帮助或提示都将不胜感激,甚至建议使用ngnix的替代方案,该方案将很容易与下一个身份验证配合使用(或者去掉url旁边的"不安全"感叹号,因为这是我使用ngniix的唯一原因。(

尝试将NodeJ的版本更新到一个新的版本,可以是这样。

相关内容

  • 没有找到相关文章

最新更新