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

Fix: CORS settings fixed #88

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
9 changes: 5 additions & 4 deletions backend/worklog/worklog/settings.py
Original file line number Diff line number Diff line change
@@ -84,11 +84,12 @@
]

# CORS
CORS_ALLOW_ALL_ORIGINS = False
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOWED_ORIGINS = [

'https://api.worklog.my',
'http://api.worklog.my',
]
# CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_CREDENTIALS = True
# CORS_ALLOW_HEADERS = '*'

# CSRF
@@ -143,7 +144,7 @@
]

MIDDLEWARE = [
# "corsheaders.middleware.CorsMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
4 changes: 4 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ import Header from './components/Header/Header';
import AuthRedirect from './components/Auth/AuthRedirect';
import ProtectedRoute from './components/Auth/ProtectedRoute';

//django에서 csrf 토큰을 쿠키에 포함에서 주기 때문에 어디서 이를 확인할지와 어떻게 보낼지 설정
axios.defaults.xsrfCookieName = 'csrftoken';
axios.defaults.xsrfHeaderName = 'X-CSRFToken';

@@ -61,6 +62,7 @@ function App() {
});
const [profileData, setProfileData] = useState(null);

//localStorage에 authToken이 있으면 true, 없으면 false
const isLoggedIn = () => {
return !!localStorage.getItem('authToken');
};
@@ -80,10 +82,12 @@ function App() {
'/friend-profile/:id',
];

//root url이면 항상 true 반환
if (location.pathname === '/') {
return true;
}

//위 리스트의 url에 현재 url이 존재하면 true 반환
return pathsWithHeader.some((path) => {
const regexPath = new RegExp('^' + path.replace(/:[^\s/]+/g, '([^/]+)') + '$');
return regexPath.test(location.pathname);
9 changes: 0 additions & 9 deletions frontend/src/pages/Main/Main.js
Original file line number Diff line number Diff line change
@@ -5,17 +5,8 @@ import 'react-responsive-carousel/lib/styles/carousel.min.css';
import typeData from '../../data/typeData.json';

function Main() {
const navigate = useNavigate();
const refs = useRef(typeData.types.map(() => React.createRef()));

const handleLoginClick = () => {
navigate('/login');
};

const handleSignUpClick = () => {
navigate('/signup/1');
};

const scrollToSection = (index) => {
const offset = 100;
const top = refs.current[index].current.getBoundingClientRect().top + window.pageYOffset - offset;
2 changes: 1 addition & 1 deletion frontend/src/utils/AdminService.js
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ const AdminService = {
},

checkUserName: (userName) => {
return API.post('/profiles/auth/check-username/', { username: userName }) // Pass the username as an object
return API.post('accounts/check-username/', { username: userName }) // Pass the username as an object
.then((response) => {
return response.data; // Return response data for further use
})