question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting HOST environment variable with anything other than a legitimate host prevents the server from running

See original GitHub issue

What version of Remix are you using?

1.4.0

Steps to Reproduce

  1. Set HOST envrionment variable to anything that is an invalid hostname. An example: http://localhost:3000
  2. Run the server

Expected Behavior

The server to run as usual.

Actual Behavior

Error: getaddrinfo ENOTFOUND http://localhost:3000
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'http://localhost:3000'
}

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
edlavercommented, Jul 8, 2022

Following up on @ElMatella’s comment, I’m trying to get a basic Remix app working with the new Shopify v3.0 CLI.

After moving the standard Remix template beneath a ‘web’ subdirectory (as detailed at: https://shopify.dev/apps/tools/cli/migrate#step-1-migrate-your-embedded-app), and adding the process.env.HOST change to remix.config.js identified by @ElMatella, I also had to change the shopify.web.toml file that was in the ./web folder to be type="frontend" instead of type="backend".

The yarn dev command from the root folder then worked for calling the v3.0 CLI shopify app dev command and doing the ngrok setup to expose the Remix app with the correct port. 🚀

I’m in the process of porting this starter app (https://github.com/WillsonSmith/shopify-remix-app) over to match the default Shopify node app template (in terms of functionality), and will then add to GitHub. Hopefully can make it a Remix stack as well!

2reactions
ElMatellacommented, Jun 1, 2022

Hey, I’m running on the exact same problem as @TheRealFlyingCoder while building a Shopify APP.

The shopify CLI rewrites the HOST variable into the .env file when running with an ngrok generated URL. I’m not saying that this is a good move from the shopify team. However, it could be cool if we could just add a parameter into remix.config.js to override this environment variable like:

module.exports = {
  serverConfiguration: {
    port: 3000, // default: process.env.PORT || 3000
    host: 'localhost', // default: process.env.HOST || 'localhost'
  }
}

This way, we could keep the current way of how it’s working while enabling to use a different value than the HOST environment variable.

Currently, the workaround I found was to overwrite the process.env.HOST variable directly into remix.config.js:

process.env.HOST = '0.0.0.0'
module.exports = {
  ...
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment Variables: What They Are and How To Use Them
While you can assign a value to an environment variable manually by using the SET command or its equivalent, you can not assign...
Read more >
Publish to IIS, setting Environment Variable - Stack Overflow
Go to your application in IIS and choose Configuration Editor . · Select Configuration Editor · Choose system. · Choose Applicationhost. · Right...
Read more >
Working with Environment Variables in Node.js - Twilio
js application. So while hosts will set a PORT variable that specifies on which port the server should listen to, modules might have...
Read more >
How to Set, List and Manage Linux Environment Variables
By convention, but not rule, environment variable names are always capitalized. Shell variables are not the same as environment variables. Shell ...
Read more >
Environment Variables in Next.js - Frontend Digest
js in production. I wanted to get it right from the beginning. This is what I learned. Let's see how we can set...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found