Open pboling opened 6 months ago
Reading here: https://upstash.com/docs/redis/quickstarts/fly
It is clear that UPSTASH_REDIS_REST_URL
isn't relevant to Fly, and info I found in that direction is out of data / incorrect.
We just need in our fly.toml
[[services]]
section:
[env]
REDIS_URL = "<your-upstash-redis-url>"
where the URL is a URL from the Upstash dashboard. I am still not sure which one exactly, but it is more clear now. Maybe it can be the redis://
URL from the flyctl output?
Oh, but that's not going to work, fly.toml
is tracked in git. We can't put secret tokens in there. The documentation is not just wrong, it is dangerous.
The only safe and reasonable answer is in the example code for setting up a local tunnel, which is very strange. This should be the primary documentation.
const redis = require("redis");
// Local Redis URL for development
const LOCAL_REDIS_URL = 'redis://localhost:10000'; // Replace with your actual local address
const REDIS_URL = process.env.NODE_ENV === 'development' ? LOCAL_REDIS_URL : process.env.REDIS_URL;
const client = redis.createClient({
url: REDIS_URL
});
client.on("error", function(error) {
console.error(error);
});
// Rest of your Redis-related code
Problem 1
There is no documentation on where to find the correct values for the following environment variables:
This (very out of date) document says to look for a
REST_URL
on the dashboard, but that doesn't exist.The dashboard appears to have been updated significantly since those screenshots, and now there is a many tabbed "Connect to your database" widget.
Unfortunately it does not have an ENV shell variable section, which is what I need for Fly.io deployment.
Other documentation appears to imply that we'd get the values from the info printed at the end of the flyctl create redis script, but the values, if they were given, were missed by me, and I copied the entire output, and still have it, perhaps they were disguised so as to appear to be relevant to something else.
Solution 1
"Connect to your database" widget should have an ENV section for the ENV variable version of the connection info.
Problem 2
Perhaps my confusion is that the value given by the script starts with
redis://
, and I've seen other documentation indicating thatUPSTASH_REDIS_REST_URL
is intended for HTTP REST interactions, so I'm expecting it to start withHTTP
, and indeed, some of the "Connect to a database" examples do have URLs starting withHTTP
.A second issue then is that the flyctl integration gives bad output that isn't relevant to what we actually need to setup Upstash Redis on our Fly.io apps.
What the output has currently (totally misleading / irrelevant to a Fly.io app needing
UPSTASH_REDIS_REST_URL
)Solution 2
Fix the output for the flyctl integration to give users the necessary info, namely: