This code doesn't url-decode the strings, so that was the issue. After removing this code, Supertokens looks at the request.headers and parses the cookie correctly itself.
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).