Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#42

Merged
merged 1 commit into from
Dec 30, 2024
Merged

#42

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions backend/transcendence/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,25 @@ def custom_exception_handler(exc, context):
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

# CORS_ORIGIN_ALLOW_ALL = True # TEST: 모든 도메인 허용 (보안 취약)
CORS_ORIGIN_ALLOW_ALL = True

CSRF_TRUSTED_ORIGINS = [
"https://10.31.5.2",
"https://localhost:443",
"https://localhost:5173",
]

CSRF_COOKIE_SECURE = True
CSRF_COOKIE_SAMESITE = "Lax"

ALLOWED_HOSTS = ["*"]

CORS_ALLOWED_ORIGINS = [
"https://10.31.5.2",
"https://localhost:443",
"https://localhost:5173",
]

CORS_ALLOW_CREDENTIALS = True # 쿠키 허용

SESSION_COOKIE_HTTPONLY = True # 쿠키를 HTTP로만 전송
# SESSION_COOKIE_HTTPONLY = True # 쿠키를 HTTP로만 전송

ROOT_URLCONF = "transcendence.urls"

Expand Down
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN npm install && \
COPY . .

# 6. Vite 서버를 실행합니다.
CMD ["npm", "run", "dev"]
CMD ["sh", "-c", "npm run build && cp -r img dist/img && npm run preview"]

# 7. 컨테이너가 노출할 포트를 설정합니다.
EXPOSE 5173
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
"preview": "vite preview --port 5173"
},
"devDependencies": {
"vite": "^5.3.4"
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/2FA.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TwoFA extends Component {

this.addEvent('click', '#resendButton', () => {
// resend msg 전송
fetch('https://localhost:443/api/send-mail/', {
fetch('https://10.31.5.2/api/send-mail/', {
method: 'GET',
credentials: 'include', // 쿠키를 포함하여 요청
})
Expand All @@ -77,7 +77,7 @@ export class TwoFA extends Component {
}

// API code 일치 확인 요청
fetch('https://localhost:443/api/verify-otp/', {
fetch('https://10.31.5.2/api/verify-otp/', {
method: 'POST',
credentials: 'include', // 쿠키를 포함하여 요청
headers: {
Expand All @@ -93,7 +93,7 @@ export class TwoFA extends Component {
if (data) {
if (data.success) {
// API!!! jwt가 있으면 해당 유저의 데이터베이스에서 언어 번호 (0 or 1 or 2) 얻어오기
fetch("https://localhost:443/api/language/", {
fetch("https://10.31.5.2/api/language/", {
method: 'GET',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
})
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Edit-Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class EditProfile extends Component {
this.is_2FA = true;

//API!! ME GET
fetch("https://localhost:443/api/me/", {
fetch("https://10.31.5.2/api/me/", {
method: 'GET',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
})
Expand Down Expand Up @@ -177,7 +177,7 @@ export class EditProfile extends Component {

this.addEvent('click', '#deleteYesButton', () => {
//API!! ME DELETE
fetch("https://localhost:443/api/me/", {
fetch("https://10.31.5.2/api/me/", {
method: 'DELETE',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
})
Expand Down Expand Up @@ -206,7 +206,7 @@ export class EditProfile extends Component {
formData.append('img_url', imageUrl);

// API!! ME PUT
fetch('https://localhost:443/api/me/', {
fetch('https://10.31.5.2/api/me/', {
method: 'PUT',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
body: formData
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/Friends-List.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class FriendsList extends Component {

mounted() {
// API !!! Friends GET
fetch("https://localhost:443/api/friends/", {
fetch("https://10.31.5.2/api/friends/", {
method: 'GET',
credentials: 'include', // 쿠키를 포함하여 요청
})
Expand Down Expand Up @@ -164,7 +164,7 @@ export class FriendsList extends Component {
else
{
// API !!! Friends POST
fetch("https://localhost:443/api/friends/", {
fetch("https://10.31.5.2/api/friends/", {
method: 'POST',
credentials: 'include', // 쿠키를 포함하여 요청
headers: {
Expand Down Expand Up @@ -196,7 +196,7 @@ export class FriendsList extends Component {
const nickname = part[0];

//API !!! userList
fetch("https://localhost:443/api/user/", {
fetch("https://10.31.5.2/api/user/", {
method: 'GET',
})
.then(response => {
Expand Down Expand Up @@ -248,7 +248,7 @@ export class FriendsList extends Component {
const uid = part[1];

// API !!! Friends DELETE
fetch("https://localhost:443/api/friends/", {
fetch("https://10.31.5.2/api/friends/", {
method: 'DELETE',
credentials: 'include', // 쿠키를 포함하여 요청
headers: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Game-Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GameCore extends Component {
this.keysPressed = {};
this.gameSocket = new WebSocket(
'wss://'
+ "localhost:443"
+ "10.31.5.2"
+ '/ws/game/'
+ this.props.uid
+ '/'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Game-Result-Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class GameResultPage extends Component {
})
};

fetch("https://localhost:443/api/game-history/tournament", {
fetch("https://10.31.5.2/api/game-history/tournament", {
method: 'POST',
credentials: 'include', // 쿠키를 포함하여 요청
headers: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Game-Tournament-Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GameTournamentCore extends Component {
this.keysPressed = {};
this.gameSocket = new WebSocket(
'wss://'
+ "localhost:443"
+ "10.31.5.2"
+ '/ws/game/'
+ this.props.uid
+ '/'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Game-matching-Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class GameMatchingCore extends Component {
this.keysPressed = {};
this.gameSocket = new WebSocket(
'wss://'
+ "localhost:443"
+ "10.31.5.2"
+ '/ws/game/vs/'
+ this.props.room
+ '/'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Home-Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Login extends Component {
setEvent () {
this.addEvent('click', '#login', () => {
// 로그인 요청
window.location.href = 'https://localhost:443/api/login/';
window.location.href = 'https://10.31.5.2/api/login/';
});
}
}
4 changes: 2 additions & 2 deletions frontend/src/components/Main-Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Menu extends Component {
});

function storeLang(value) {
fetch("https://localhost:443/api/language/", {
fetch("https://10.31.5.2/api/language/", {
method: 'PUT',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
headers: {
Expand Down Expand Up @@ -112,7 +112,7 @@ export class Menu extends Component {

this.addEvent('click', '#Logout', () => {
// API !! ME POST
fetch("https://localhost:443/api/me/", {
fetch("https://10.31.5.2/api/me/", {
method: 'POST',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Profile-Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class ProfileInfo extends Component {
this.rate = null;
this.games = null;

fetch(`https://localhost:443/api/user/${this.props.uid}`, {
fetch(`https://10.31.5.2/api/user/${this.props.uid}`, {
method: 'GET',
credentials: 'include', // 쿠키를 포함하여 요청 (사용자 인증 필요 시)
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Tournament-Setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class TournamentSetting extends Component {

const translations = this.translations;

fetch("https://localhost:443/api/game-history/tournament", {
fetch("https://10.31.5.2/api/game-history/tournament", {
method: "GET",
credentials: "include", // 쿠키 포함
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/showLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { initializeRouter, changeUrl, parsePath } from "./router.js";
import { getCookie } from "./jwt.js";
import { createLoadingElement, addLoadingStyles } from "./loadingComponents.js";

const WEBSOCKET_URL = 'wss://localhost:443/ws/online/';
const WEBSOCKET_URL = 'wss://10.31.5.2/ws/online/';

export const closeAllSockets = (socketList) => {
socketList.forEach(socket => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const API_BASE_URL = "https://localhost:443/api";
export const API_BASE_URL = "https://10.31.5.2/api";

// https://docs.djangoproject.com/en/5.1/howto/csrf/#using-csrf-protection-with-ajax
function getCookie(name) {
Expand Down
3 changes: 3 additions & 0 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { defineConfig } from "vite";
export default defineConfig({
server: {
host: "0.0.0.0",
logLevel: "silent",
https: false,
port: 5173,
hmr: {
clientPort: 5173,
protocol: "ws",
Expand Down
2 changes: 1 addition & 1 deletion run_frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

cp .env.local .env

cd frontend && npm install && npm run dev
cd frontend && npm install && npm run build && cp -r img dist/img && npm run preview
Loading