In the example below I perform 2 Post Fetch requests. The function 'mdbSetFav' has no cors issues. But the function 'mdbCreateList' has cors issues. Yet the list gets created so I don't understand why I get an error?
mdbCreateList({context},data){
fetch(`${BaseURL}list?api_key=${APIKey}&session_id=${sessionStorage.getItem('sessionID')}`,{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(function(response) {
if (response.status === 401) {
console.log(response)
router.push('/login')
}
return response.text().then(function(text) {
let json = JSON.parse(text)
console.log(json)
return;
})})
.then(function(){
context.dispatch('mdbLists');
})
.catch(function(error){
console.error(error);
});
},
mdbSetFav({state},data){
console.log(JSON.stringify(data))
fetch(`${BaseURL}account/${state.account.id}/favorite?api_key=${APIKey}&session_id=${sessionStorage.getItem('sessionID')} `,{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(function(response) {
if (response.status === 401) {
console.log(response)
router.push('/login')
}
return response.text().then(function(text) {
let json = JSON.parse(text)
console.log(json)
return;
})})
.then(function(){
//context.dispatch('mdbLists');
})
.catch(function(error){
console.error(error);
});
},
The error:
Access to fetch at 'https://api.themoviedb.org/3/list?api_key=***&session_id=***' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled
and a warning:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.themoviedb.org/3/list?api_key=***&session_id=*** with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Can anyone help me out?
찾으시는 영화나 TV 프로그램이 없나요? 로그인 하셔서 직접 만들어주세요.
Want to rate or add this item to a list?
Not a member?
Travis Bell님의 댓글
1월 9, 2019 at 3:50 오후
Hi @RuneClaeys,
Indeed, it seems as though the
POST /3/list
method does not have the proper CORS headers added. I'll get them added and let you know when it is working.Thanks.
RuneClaeys님의 댓글
1월 10, 2019 at 4:07 오전
Thanks for the quick response. I've come across an other problem. Is it possible that there's an error with the DELETE a list call in version 3 of the API? It keeps telling me I'm not authorized even with a sessionID I just requested?
Travis Bell님의 댓글
2월 8, 2019 at 4:45 오후
I've created a new ticket that you can follow and vote on about the CORS issue here.
With regards to your second question, have completed step #2 in the walkthrough?
kibice님의 댓글
6월 27, 2019 at 5:00 오전
Hi @travisbell, Could you share roadmap when this fix will be available on production? Thank you in advance.
Travis Bell님의 댓글
7월 2, 2019 at 10:34 오전
Hi @kibice, you can follow the ticket above. That way you will be notified of any changes to it.
lawrencemhoni님의 댓글
9월 19, 2019 at 8:01 오전
Hello @travisbell I'm facing the same issue. How do I go about it?
Travis Bell님의 댓글
9월 20, 2019 at 6:11 오후
Hey @lawrencemhoni, the fix for this actually went live last week, I just hadn't updated the ticket yet. You can see here there is now the correct headers (
Access-Control-Allow-Origin
) being returned:Request
Response
lawrencemhoni님의 댓글
9월 21, 2019 at 12:45 오후
Fantastic! Thank you @travisbell
lawrencemhoni님의 댓글
9월 21, 2019 at 1:06 오후
@travisbell for a moment it worked... Maybe I did something right... But right now this is what is being returned.
Travis Bell님의 댓글
9월 21, 2019 at 2:43 오후
There's no session ID being specified in your request. You need to pass a approved session in as a
session_id
param.lawrencemhoni님의 댓글
9월 22, 2019 at 5:25 오전
@travisbell
returns
lawrencemhoni님의 댓글
9월 22, 2019 at 5:28 오전
@travisbell
As shown above, I would love to have my accountID so that I may access my watchlist using
If we can get this to work, you will be my hero of the day.