waku-org / waku-frontend

Waku's frontend. Interact with your waku node via this simple user interface
1 stars 2 forks source link

service endpoint as environment variable #31

Closed kaichaosun closed 3 months ago

kaichaosun commented 3 months ago

Fix https://github.com/waku-org/waku-frontend/issues/30

alrevuelta commented 3 months ago

@kaichaosun Thanks!

How is this meant to be used? I have tried

VITE_SERVICE_ENDPOINT=http://someurl.com npm run dev

and

export VITE_SERVICE_ENDPOINT=http://someurl.com
npm run dev

But when I check in settings I still see the old hardcoded one.

image
kaichaosun commented 3 months ago

You can set the .env with a default one, and override the .env if needed.

alrevuelta commented 3 months ago

You can set the .env with a default one, and override the .env if needed.

Yes, my question is how to override it. With the example I shared above is not overridden. How can I override it?

kaichaosun commented 3 months ago

It works with my machine with this command VITE_SERVICE_ENDPOINT=127.0.0.2 npm run dev

alrevuelta commented 3 months ago

@kaichaosun I found the issue, would say it's a bug.

The first time one connects to the frontend, you provide a username. That's saved in localStorage but also apiEndpoint is saved. This means that when getItem("apiEndpoint") is called, you are reloading the old endpoint and the env variable VITE_SERVICE_ENDPOINT is ignored.

Mind having a look into this issue?

kaichaosun commented 3 months ago

localStorage apiEndpoint is set when user clicks save settings. If you don't want this feature, just remove the button here https://github.com/threeproto/ferry-chat/blob/main/src/App.tsx#L27. I don't exactly know what's the expected way in waku-frontend, so feel free to do any changes you feel comfortable.

alrevuelta commented 3 months ago

Fixed by #33