Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUIRREL_BASE_URL environment variable not working in development #1028

Closed
rmiller61 opened this issue Aug 18, 2022 · 10 comments
Closed

QUIRREL_BASE_URL environment variable not working in development #1028

rmiller61 opened this issue Aug 18, 2022 · 10 comments

Comments

@rmiller61
Copy link

rmiller61 commented Aug 18, 2022

Bug Report

Current Behavior
I'm using local-ssl-proxy for development which means my base url is https://localhost:3000. But no matter what I set QUIRREL_BASE_URL to in my .env files, Quirrel seems to still use the default (insecure) http://localhost:3000 as the base url. As a result, my queues/events are not working.

Input Code

.env

QUIRREL_BASE_URL="https://localhost:3000"

package.json

  "scripts": {
    "dev": "concurrently 'blitz dev -p 3001 & local-ssl-proxy --key localhost-key.pem --cert localhost.pem --source 3000 --target 3001' 'quirrel'",
    ...
  },

Expected behavior/code
Quirrel should be using the environment variable I've set for the base url.

Environment

  • Quirrel 1.9.3
  • Node 16.13.2
  • Yarn 1.22.18
  • Blitz 0.45.4

Possible Solution

Additional context/Screenshots
In the development UI, on the network tab it is showing the wrong (default) base URL being called.
Screen Shot 2022-08-17 at 9 31 03 PM

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

Judging from the code you sent, it looks like you should be using https://localhost:3001. Does that work?

@rmiller61
Copy link
Author

Nope I've tried every variation of https:// vs http://, port 3000 vs 3001. The problem seems to be that Quirrel is ignoring my QUIRREL_BASE_URL environment variable. At least that's what my assumption would be from that screenshot of the network tab where the url param is always http://localhost:3000 regardless of what the environment variable is.

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

The QUIRREL_BASE_URL variable is picked up by the Quirrel npm library you're importing in your Blitz app. Can you check if other environment variables from that file are being picked up by Blitz?

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

Aside from that, could you elaborate on why you're trying to guard Quirrel behind an SSL proxy locally? Would love to learn more about that.

@rmiller61
Copy link
Author

Yeah all other environment variables are working and if I console.log(process.env.QUIRREL_BASE_URL) on the server it prints the correct value.

As for the SSL, I actually don't even remember why I'm using a proxy. If I start my application without the proxy, with just concurrently 'blitz dev' 'quirrel' then everything does work as intended (in retrospect that was probably worth mentioning in the bug report, so apologies on not making that clear).

Regardless, I still thought this was worth opening the issue because it does seem Quirrel is ignoring the environment variable, and if that's the case I'm concerned what will happen in production when I try to set the variable.

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

When you write "the application seems to still use the default" in the issue, what is "the application" referring to, Quirrel or your Blitz application?

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

If it's referring to Quirrel, I think I have an idea of what's causing what you're seeing, and it checks out that you're seeing the Dev UI call the local quirrel server via HTTP and not HTTPS. In local dev, I consider that very acceptable. Can you elaborate on why that's a problem for your usecase?

@rmiller61
Copy link
Author

I mean Quirrel. I've updated the description for clarity.

I don't think HTTPS is the issue. Even if I stop using the proxy, Quirrel still won't call any url other than http://localhost:3000. For example, if I set QUIRREL_BASE_URL="http://localhost:3001" and start with blitz dev -p 3001, Quirrel still uses a http://localhost:3000 endpoint even though the server is http://localhost:3001.

Like I said, it's not necessarily a problem in development because I can just not use proxies or port forwarding. But this does seem to go against the expected behavior of Quirrel. And I'm concerned that if the environment variable doesn't work in development, then it won't in production, which would be a problem.

@Skn0tt
Copy link
Member

Skn0tt commented Aug 18, 2022

I think the problem is that in your dev script, the 'quirrel' call won't pick up .env files. Could you try changing it to 'QUIRREL_BASE_URL="http://localhost:3001" quirrel'? That should make it pick up the environment variable. Alternative, you can look at tools like https://www.npmjs.com/package/dotenv-cli.

@rmiller61
Copy link
Author

perfect, that worked. Much thanks! I'll mark this as closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants