Skip to content

Commit

Permalink
Fix allowed origins to include Vercel deployment URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagi132 committed Jul 1, 2024
1 parent a8c1d96 commit e3755a6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const server = http.createServer(app);

// CORS setup
const allowedOrigins = process.env.NODE_ENV === 'production'
? ['https://ping-pong-online.vercel.app/']
? ['https://ping-pong-online.vercel.app']
: ['http://localhost:3000'];

const corsOptions = {
Expand Down
2 changes: 1 addition & 1 deletion src/Gameplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Gameplay = () => {


useEffect(() => {
const newSocket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app/' : 'http://localhost:4000',
const newSocket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app' : 'http://localhost:4000',
{
withCredentials: true,
transportOptions: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Lobby() {

useEffect(() => {
// Connect to the socket.io server
const newSocket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app/' : 'http://localhost:4000',
const newSocket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app' : 'http://localhost:4000',
{
withCredentials: true,
transportOptions: {
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Lobby from './components/Lobby';
import GameplayMenu from "./GameplayMenu";
import io from 'socket.io-client';

const socket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app/' : 'http://localhost:4000',
const socket = io(process.env.NODE_ENV === 'production' ? 'https://ping-pong-online.vercel.app' : 'http://localhost:4000',
{
withCredentials: true,
transportOptions: {
Expand Down

0 comments on commit e3755a6

Please sign in to comment.