riverqueue / riverui

A web interface for River, fast and reliable background jobs in Go.
https://ui.riverqueue.com/
Mozilla Public License 2.0
43 stars 3 forks source link

Frontend Undefined Variable #60

Closed Zibbp closed 1 week ago

Zibbp commented 1 week ago

Attempting to browse the WebUI results in the API requests returning a status of 404. Looks like this is because a variable in the frontend is undefined.

http://localhost:8080/undefined/jobs?state=running&limit=20

I'm guessing this is the undefined part. https://github.com/riverqueue/riverui/blob/698220a7e18ed3de3666b41633740f9fa6770812/ui/src/utils/api.ts#L24-L28

Vite env vars are statically replaced at build time. I don't see a real .env in the UI directory, resulting in the variable being undefined.

The backend/API is correctly functioning.

$ curl localhost:8080/api/states
{"available":0,"cancelled":0,"completed":66,"discarded":90,"pending":0,"retryable":0,"running":0,"scheduled":0}

Unless I'm missing a design choice, removing the env variable and hardcoding /api should be fine as they're hosted on the same service/port. Not sure if the below will work being a 'partial' URL but the idea is:

 export function APIUrl(path: string, query?: URLSearchParams) { 
   return `/api${path}${ 
     query ? `?${query}` : "" 
   }`; 
 } 
bgentry commented 1 week ago

Hi @Zibbp, sorry you're running into this. Can you confirm if you're using the prebuilt docker image, or something else?

bgentry commented 1 week ago

@Zibbp I'm seeing this issue in the prebuilt binaries, while the Docker images appear to be fine.

Zibbp commented 1 week ago

Sorry, forgot to mention. I'm using the prebuilt binaries. I'll try out the Docker image now.

Edit: Can confirm that the docker image works.

Zibbp commented 1 week ago

Thank you for the quick fix!