16

I have an api created and hosted on Heroku. I have my web app running on localhost. I am using NextJS for my app. I am able to access all my apis hosted on Heroku via my web app which is running on localhost. I have one api which checks whether a cookie is available or not, I am calling the api in the getInitialProps method of the _app.js file of my NextJS app which is the entry point of the framework. If I comment that api call code then I don't get any error , but I need to check whether cookie is present or not so calling that code gives an error saying

Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:*.herokuapp.com, DNS:herokuapp.com

Also my cookie is not saved in the browser when I login. It works fine on postman so no problem from my api side and I can see the cookie in the postman. I did set following in my NodeJS app

app.set("trust proxy", true);

I am using the cookie-session library in my express Nodejs app

BraveEvidence
  • 53
  • 11
  • 45
  • 119

2 Answers2

0

in my case https://github.com/ushelp/EasyQRCodeJS-NodeJS/issues/30#issuecomment-1221164642 i always manual on create systemd file but i got same issue when tried using pm2.

i have an issue from my ecosystem.config.js where thats handle of env ( process.env.any )

something your value to pointing / save / load online its still on localhost or an ipaddress instead of your custom domain on VPS server these issue when u are using certbot instead of buying ssl.

these random error, in my case you can check on the above link for more detail but in short its just because you are using ipaddress or localhost in your code.

try to change your hardcode everything that point to correct env

but in your case you are using heroku thats mean you need to define
on reveal vars because heroku is not using an env file

here more for you ( put all your env to ) heroku --> setting --> Config Vars --> Reveal Config Vars

Yogi Arif Widodo
  • 563
  • 6
  • 22
-1

Read this article: https://devcenter.heroku.com/articles/ssl

It's about installing certificates. For me it looks that just the certificate is signed for localhost. The browser will reject it, because you access the site by another domain name.

So you have to self-sign a certificate and upload it, or buy a trusted certificate.

bitbybit
  • 121
  • 5