Skip to content

Commit

Permalink
Fix websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
SeoulSKY committed Jun 3, 2024
1 parent 414890d commit 0ce71c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
container_name: web-server
depends_on:
- chat-server
environment:
- VITE_APP_PROD=1
ports:
- "3000:3000"
volumes:
Expand Down
15 changes: 6 additions & 9 deletions web-server/package-lock.json

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

3 changes: 2 additions & 1 deletion web-server/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const APP_NAME = "GoChat";

export const SERVER_HOST = import.meta.env.PROD ? "https://gochat.seoulsky.org/api/" : "http://localhost:4000/api/";
export const SERVER_HOST =
import.meta.env.VITE_APP_PROD ? "https://gochat.seoulsky.org/api/" : "http://localhost:4000/api/";
3 changes: 2 additions & 1 deletion web-server/src/pages/ChatRoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export default function ChatRoom() {
const inputRef = useRef<HTMLInputElement>(null);
const scrollRef = useRef<HTMLDivElement>(null);

const { sendMessage, lastMessage, readyState } = useWebSocket(SERVER_HOST.replace(/^https?:/, "ws") + "ws");
const { sendMessage, lastMessage, readyState } = useWebSocket(
SERVER_HOST.replace(/^https?/, import.meta.env.VITE_APP_PROD ? "wss" : "ws") + "ws");
const [messages, setMessages] = useState<Message[]>([]);
const [input, setInput] = useState("");
const [isOverflow, setIsOverflow] = useState(false);
Expand Down

0 comments on commit 0ce71c2

Please sign in to comment.