codestates / codestates/Subllet
[ERR] No 'Access-Control-Allow-Origin' header is present on the requested resource.
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### 어떤 에러인가요?
- 클라이언트에서 서버로 API 요청을 보낼 때, cors 에러가 발생했습니다.
### 에러 메시지
```shell
Access to XMLHttpRequest at 'http://ec2-18-212-9-107.compute-1.amazonaws.com/auth/login' from origin 'http://subllet.s3-website-us-east-1.amazonaws.com/' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```
### 에러 핸들링 방법
- cors.use안 origin 값의 배열을 제거했습니다. 로컬 환경과 배포 환경의 차이를 알 수 있었습니다.
- 추가적으로 대소문자 구분도 배포 환경에서 strict 하다는 것을 확인했습니다.
```js
app.use(
cors({
origin: "https://localhost:3000",
credentials: true,
methods: ["GET", "POST", "OPTIONS", "PATCH", "DELETE"],
})
);
```
### 에러 핸들링을 위해 참고한 레퍼런스 링크
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.