
Access to XMLHttpRequest at 'http://localhost:5000/users/reset' from origin 'http://localhost:3000' has been blocked by CORS policy.
브라우저가 두 도메인(http://localhost:3000과 http://localhost:5000)이 다른 것으로 간주하고 요청을 차단
백엔드에서 프론트엔드의 요청을 허용하도록 설정하지 않았기 때문.
npm install cors
app.listen(process.env.PORT, () => {
console.log(`Server on port number : ${process.env.PORT}.`);
});
const app = express();
// CORS 설정
app.use(
cors({
origin: 'http://localhost:3000', // 허용할 프론트엔드 URL
methods: ['GET', 'POST', 'PUT', 'DELETE'], // 허용할 HTTP 메서드
credentials: true, // 쿠키 인증 정보 사용 시 설정
})
);