我正在尝试向 发出帖子请求,URL = "https://sambhav.daily.co/v1/rooms"
但我收到了被 cors 政策阻止的错误
addRoom(): Observable<any> {
const headers = new HttpHeaders()
.set("content-type", "application/json")
.set("Access-Control-Allow-Origin", "http://localhost:8000")
.set("Access-Control-Allow-Methods", "GET,POST,PATCH,DELETE,PUT,OPTIONS")
.set(
"Access-Control-Allow-Headers",
"Origin, Content-Type, X-Auth-Token, content-type"
)
.set(
"Authorization",
`Bearer <API-KEY>`
);
return this.http
.post(URL, { headers: headers })
.map((response: any) => response.data)
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误
Access to XMLHttpRequest at 'https://sambhav.daily.co/v1/rooms' from origin 'http://localhost:8000' 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.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
90 次 |
最近记录: |