-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Fix issue #124 wrong servers when installed #127
Fix issue #124 wrong servers when installed #127
Conversation
the CUSTOM_LEMMY_SERVER env variable is now injected as a variable defined in vite.config.ts, allowing it to persist even after the PWA has been installed
Looks great! |
I forgot to test this in production. Essentially, post build-time, you should be able to configure custom servers If I do:
The lemmy.ml server is not being picked up. So I am reverting for now. Feel free to make another PR. |
Hey @aeharding I see your point, I admit I worked under the (wrong) assumption that they should be configured at compile time. I'll look for another way, as the PWA is misbehaving anyway after installation, but yes, for now it's best to revert. |
Thanks @gianmarcotoso! |
@aeharding I'm thinking that there is no good solution using env in this case, as it does not carry over when installing the PWA. I was thinking about adding the ability for the user add and remove custom servers at runtime, saving them in localstorage. Would this approach be ok with you? Where should this happen, in the servers screen or in the settings screen? Or maybe it could suffice saving the value of |
The custom lemmy servers should not be user configurable. Maybe there is a something we can hook into on vite-pwa to move over custom servers? Otherwise, we could make an express route in server.mjs to respond with servers (with aggressive 1 day caching) via xhr. But that's async, so would be a bit more work. |
Hm, I see. So, I've tried using localStorage to save the content of window.CUSTOM_LEMMY_SERVERS when it's available and it does work in production, so that might be a quick and viable way to solve this. Can I ask, why shouldn't the servers be configurable (on a per-user basis) if the app lives entirely on the user's device? I'm very likely missing a piece of the puzzle here :) |
Fixes Issue #124
Defines the
CUSTOM_LEMMY_SERVERS
as a variable throughvite.config.ts
, allowing it to be present after PWA installation.This requires reading the the environment via Vite's
loadEnv
function, and define the config using a function in order to be able to read the currentmode
(development
,production
,test
).The
CUSTOM_LEMMY_SERVERS
can be defined in the environment either system wide or through a.env
file such as.env.production.local
or.env.development.local
(the.local
is not strictly needed, but.local
files are gitignored).Sidenote: I added a
.prettierrc
because I use different settings and they were wreaking havoc on the code, this way it should be consistent.