cli icon indicating copy to clipboard operation
cli copied to clipboard

Request: Offline/Cached Environment Variables

Open neverabsolute opened this issue 1 year ago • 2 comments

I've been thinking it would be nice for the CLI to be able to cache environment variables.

The use case I'm thinking of here is CLI usage without internet or during a Railway outage. I know this presents a certain security risk but if you're already logged in to the CLI and someone gains physical access to your machine it's already game over. (Could also make offline access/caching opt-in only)

Example:

railway login && railway link -> link to a project

railway run pnpm dev -> runs as expected, pulling context from environment variables set in the project

oh great heavens internet pooped

railway run pnpm dev -> runs as expected, pulling context from last known environment variables set in the project

neverabsolute avatar Mar 10 '23 18:03 neverabsolute

oh great heavens!

alexng353 avatar Mar 11 '23 03:03 alexng353

I have to wonder, how would caching work? I'm assuming that there would need to be a timestamp saved in the local cache and some kind of extra endpoint for checking if the environment variables on apiv2 have changed since the last time you got them. Or hash cached variables on client side to match against server side hash?

Either way I can't really think of how to do it without checking the backend every time, unless the offline would just act as a fallback, working only if the api call fails.

note: I am working on POC for second idea now that I've had it lol

alexng353 avatar Apr 29 '23 00:04 alexng353