Skip to content

Commit

Permalink
web: Always use an absolute url when connecting to hubs
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddiM8 committed Jul 3, 2024
1 parent 5996ab3 commit 6d4d111
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 67 deletions.
5 changes: 3 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
condition: service_healthy
environment:
PLANERA_FRONTENDURL: https://localhost:2000
PLANERA_EMAILCONFIRMATION: false
PLANERA_EMAILCONFIRMATION: "false"
PLANERA_POSTGRES__HOST: "db:5432"
PLANERA_POSTGRES__USER: planera
PLANERA_POSTGRES__PASSWORD: planera
Expand All @@ -45,6 +45,7 @@
image: planera-web
environment:
ORIGIN: https://localhost:2000
VITE_PUBLIC_API_URL: https://localhost:2000/api
build:
context: .
dockerfile: web/Dockerfile
dockerfile: web/Dockerfile
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
condition: service_healthy
environment:
PLANERA_FRONTENDURL: http://localhost:2000
PLANERA_EMAILCONFIRMATION: false
PLANERA_DISABLEREGISTRATION: false
PLANERA_EMAILCONFIRMATION: "false"
PLANERA_DISABLEREGISTRATION: "false"
PLANERA_POSTGRES__HOST: "db:5432"
PLANERA_POSTGRES__USER: planera
PLANERA_POSTGRES__PASSWORD: planera
Expand All @@ -46,3 +46,4 @@
restart: always
environment:
ORIGIN: http://localhost:2000
VITE_PUBLIC_API_URL: https://localhost:2000/api
2 changes: 1 addition & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.5
FROM node:20.12
WORKDIR /app
COPY ["web/package.json", "web/package-lock.json", "web/"]
WORKDIR /app/web
Expand Down
132 changes: 71 additions & 61 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion web/src/lib/hubs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {type HubConnection, HubConnectionBuilder} from "@microsoft/signalr";

async function buildHub(name: string): Promise<HubConnection> {
// Make sure the url is absolute
const apiUrl = import.meta.env.VITE_PUBLIC_API_URL.match(/^https?:\/\//)
? import.meta.env.VITE_PUBLIC_API_URL
: window.location.origin + import.meta.env.VITE_PUBLIC_API_URL
return new HubConnectionBuilder()
.withUrl(`${import.meta.env.VITE_PUBLIC_API_URL}/hubs/${name}`)
.withUrl(`${apiUrl}/hubs/${name}`)
.withAutomaticReconnect()
.build();
}
Expand Down

0 comments on commit 6d4d111

Please sign in to comment.