Skip to content
Discussion options

You must be logged in to vote

Finally, I figured it out.

The Reason

Let's say my website domain is api.example.com.

  1. Most Linux has a global environment variable: HOST=localhost.
  2. AdonisJS gives environment variables higher priority than those from .env files. So your HOST=api.example.com in your .env file is always ignored. HOST is still localhost.
  3. AdonisJS start HTTP/HTTPS server with .listen({ host: this.application.env('HOST'), port: this.application.env('PORT') }). For HTTPS server, it accepts only requests whose domain match HOST, which is still localhost.
  4. As a result, when you visit https://api.example.com/, server refuses your connection.

Solution 1

Set system environment variables. If you only have one app on…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RomainLanz
Comment options

Answer selected by guoyunhe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants