nhost / hasura-auth

Authentication for Hasura.
https://nhost.io
MIT License
386 stars 114 forks source link

signInEmailPasswordless gives error 500 after updates #241

Closed fonksiyoneltip closed 2 years ago

fonksiyoneltip commented 2 years ago

I've updated Nhost CLI, node packages of my project and also Docker. After updates, signInEmailPasswordless('theEmailAddress') stopped working (on working old project) . The only error I get is:

{message: "Request failed with status code 500", status: 500, error: "Internal Server Error"}

There is nothing but this I can share.

EDIT: I've used JS client nhost.auth.signIn({ email: 'theemailaddress' }).catch(e => { console.error(e) }) with the same output

elitan commented 2 years ago

Can you check the logs (nhost logs -f) while signing up? Maybe there is some clues there.

fonksiyoneltip commented 2 years ago

I think these are what you are looking for.

akademi-funny_carson-auth-1:
  {
    "level": 40,
    "time": 1663829608553,
    "pid": 18,
    "hostname": "3191a03cd0c8",
    "msg": "No template found at /app/email-templates/en/signin-passwordless/body.txt"
  }
akademi-funny_carson-auth-1:
Error: connect ECONNREFUSED 172.31.0.8:1897 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)
akademi-funny_carson-auth-1:
{
    "level": 30,
    "time": 1663829608577,
    "pid": 18,
    "hostname": "3191a03cd0c8",
    "req": {
      "id": 16952,
      "method": "POST",
      "url": "/signin/passwordless/email",
      "query": {},
      "params": {},
      "headers": {
        "host": "localhost:1337",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15",
        "content-length": "48",
        "accept": "application/json, text/plain, */*",
        "accept-encoding": "gzip, deflate",
        "accept-language": "en-US,en;q=0.9",
        "content-type": "application/json",
        "origin": "http://localhost",
        "referer": "http://localhost/",
        "x-forwarded-for": "172.31.0.1",
        "x-forwarded-host": "localhost:1337",
        "x-forwarded-port": "1337",
        "x-forwarded-prefix": "/v1/auth",
        "x-forwarded-proto": "http",
        "x-forwarded-server": "c64b9468f920",
        "x-real-ip": "172.31.0.1"
      },
      "remoteAddress": "::ffff:172.31.0.6",
      "remotePort": 39740
    },
    "res": {
      "statusCode": 500,
      "headers": {
        "x-dns-prefetch-control": "off",
        "x-frame-options": "SAMEORIGIN",
        "strict-transport-security": "max-age=15552000; includeSubDomains",
        "x-download-options": "noopen",
        "x-content-type-options": "nosniff",
        "x-xss-protection": "1; mode=block",
        "access-control-allow-origin": "*",
        "surrogate-control": "no-store",
        "cache-control": "no-store, no-cache, must-revalidate, proxy-revalidate",
        "pragma": "no-cache",
        "expires": "0",
        "content-security-policy": "default-src 'none'",
        "content-type": "text/html; charset=utf-8",
        "content-length": 148
      }
    },
    "err": {
      "type": "Error",
      "message": "failed with status code 500",
      "stack": "Error: failed with status code 500\n    at ServerResponse.onResFinished (/app/node_modules/.pnpm/pino-http@5.8.0/node_modules/pino-http/logger.js:77:38)\n    at ServerResponse.emit (node:events:525:35)\n    at onFinish (node:_http_outgoing:909:10)\n    at callback (node:internal/streams/writable:554:21)\n    at afterWrite (node:internal/streams/writable:499:5)\n    at afterWriteTick (node:internal/streams/writable:486:10)\n    at processTicksAndRejections (node:internal/process/task_queues:82:21)"
    },
    "responseTime": 134,
    "msg": "request errored"
  }
fonksiyoneltip commented 2 years ago

I've reinstalled CLI, created a fresh new NextJS project but with the same result. Am I the only one having problem with passwordless email sign in?

EDIT: NextJS app works flawlessly with remote server, using

const nhost = new NhostClient({
  region: 'eu-central-1',
  subdomain: 'mysubdomain'
});

The problem is with my local nhost setup, it's certain now. But IDK how it got broken just by updating Nhost and docker. I will uninstall docker completely and try again.

fonksiyoneltip commented 2 years ago

Nope. Whatever I do, I cannot make magic link work on local env

elitan commented 2 years ago

Can you set the auth.smtp.port to 1025 in the nhost/config.yaml file. Then restart nhost up and try again.

Relevant: https://github.com/nhost/cli/pull/360

fonksiyoneltip commented 2 years ago

Thanks @elitan, it worked. For old projects deployed to Nhost, a new deployment is required with the new value.

plmercereau commented 2 years ago

This issue is solved, closing it. Thanks!