Forum Settings
Forums
New
Nov 27, 2016 6:39 PM
#1

Offline
May 2012
25827
I'm making a bit of a short oversight of my own list and would like to use the following xml to then convert to json with javascript:

https://myanimelist.net/malappinfo.php?u=rafaeldejongh&status=all&type=anime

However, I've reached a dead end as whatever I try (JSONP, CRON, ETC) I always get faced with the following error:

XMLHttpRequest cannot load https://myanimelist.net/malappinfo.php?u=rafaeldejongh&status=all&type=anime. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

Does anyone know another way to bypass this or would it be possible to add this header to the malappinfo perhaps?

Here's the Codepen I'm making it in for: https://codepen.io/RafaelDeJongh/pen/eBRJjx?editors=0010

Thanks in advance for further information.
Nov 28, 2016 12:43 AM
#2

Offline
Jul 2013
36274
What you are trying to perform here is a cross-origin XHR request. Due to security reasons however cross-origin XHR requests are not allowed. There are things like CORS which were made to let you make cross-origin XHR requests, but using it is only possible if the target server permits it.

For example if this header is present in the response then you should be able to use CORS, but based on the error message you get it doesn't seem like it. (can't really confirm though since I never actually tried to use CORS or the MAL api myself)
Access-Control-Allow-Origin: *


Alternatively you could write a server-side script on the same server as your javascript to retrieve the data with, and then make the XHR request to that script instead.
For those who seek perfection, there can be no rest on this side of the grave.
Hope is the first step on the road to disappointment.
Nov 28, 2016 4:11 AM
#3

Offline
May 2012
25827
Tyrantarmy6 said:
What you are trying to perform here is a cross-origin XHR request. Due to security reasons however cross-origin XHR requests are not allowed. There are things like CORS which were made to let you make cross-origin XHR requests, but using it is only possible if the target server permits it.

For example if this header is present in the response then you should be able to use CORS, but based on the error message you get it doesn't seem like it. (can't really confirm though since I never actually tried to use CORS or the MAL api myself)
Access-Control-Allow-Origin: *


Alternatively you could write a server-side script on the same server as your javascript to retrieve the data with, and then make the XHR request to that script instead.


That's indeed correct, that information I've managed to gather already but alas that didn't really help me much finding a solution for this (if there is actually any). The fact that I want to keep create this on Codepen doesn't really help as I also don't have much control in terms of accessing other files other than HTML,CSS and JavaScript.
Nov 28, 2016 4:34 AM
#4

Offline
Jul 2013
36274
RafaelDeJongh said:
That's indeed correct, that information I've managed to gather already but alas that didn't really help me much finding a solution for this (if there is actually any). The fact that I want to keep create this on Codepen doesn't really help as I also don't have much control in terms of accessing other files other than HTML,CSS and JavaScript.


Hmmm well there's one thing you could try. Take a look at the accepted answer for this stackoverflow question.
I don't know if this works since I would never want to rely on these kinds of solutions even if it does, but if you absolutely need to make this work with javascript through codepen and you don't mind using this kind of solution (which I don't recommend) then you could try it out.

If it doesn't work then I don't know any solutions other than server side scripts. You could do it through localhost for example.
For those who seek perfection, there can be no rest on this side of the grave.
Hope is the first step on the road to disappointment.
Nov 28, 2016 4:56 AM
#5

Offline
May 2012
25827
Tyrantarmy6 said:
RafaelDeJongh said:
That's indeed correct, that information I've managed to gather already but alas that didn't really help me much finding a solution for this (if there is actually any). The fact that I want to keep create this on Codepen doesn't really help as I also don't have much control in terms of accessing other files other than HTML,CSS and JavaScript.


Hmmm well there's one thing you could try. Take a look at the accepted answer for this stackoverflow question.
I don't know if this works since I would never want to rely on these kinds of solutions even if it does, but if you absolutely need to make this work with javascript through codepen and you don't mind using this kind of solution (which I don't recommend) then you could try it out.

If it doesn't work then I don't know any solutions other than server side scripts. You could do it through localhost for example.


Safly enough those "solutions" or let's say workarounds didn't help either. Already tried those out :/

I'm probably going to see to do it locally and see how it reacts on my personal server instead.

Thanks for the information!
Nov 28, 2016 1:24 PM
#6
Lovely person

Offline
Mar 2016
314
I'm stuck with this as well.

I've found a solution that is to use crossorigin.me, as like the following:

https://crossorigin.me/https://myanimelist.net/malappinfo.php?u=FoxInFlame&type=anime&status=all


It works, but it's way slower. I might just make my own server script...
FoxInFlameNov 28, 2016 3:38 PM
Nov 28, 2016 5:41 PM
#7

Offline
May 2012
25827
FoxInFlame said:
I'm stuck with this as well.

I've found a solution that is to use crossorigin.me, as like the following:

https://crossorigin.me/https://myanimelist.net/malappinfo.php?u=FoxInFlame&type=anime&status=all


It works, but it's way slower. I might just make my own server script...


Awesome! This indeed "fixed" the problem pretty much, I already tried various other "Proxies" but they didn't work too well with the xml file from MAL, but this one does seem to work! But as said the load time sure is a bit steep, so in case you do make your own server script let me know then I'd be happy to host it on my server as well!

Edit: I did send a Support Request regarding this issue as it's really something related to the flag set on MAL's server. I do hope they would add this so other people can make use of it easier! (Tried now to see if it would fetch locally or via github but none of both works properly).
RafaelDeJonghNov 29, 2016 8:58 AM
Nov 29, 2016 11:00 AM
#8
Lovely person

Offline
Mar 2016
314
Temporarily, you could use the small server script I have hosted on my server.

http://www.foxinflame.tk/dev/matomari/malappinfo.php


It accepts the same parameters as the official malappinfo. The only problem with this is that my hoster isn't stable, that it is still a bit slow (it still has to grab from the official malappinfo), and finally, that it's not HTTPS.

The code is at GitHub, if you want to host it on your own.
FoxInFlameNov 29, 2016 11:06 AM
Dec 2, 2016 9:42 PM
#9

Offline
May 2012
25827
Pretty much finished this little project which can be seen/used here: https://rafaeldejongh-sites.ga/MyAnimeList-User-Stats/

In the end I've used FoxInFlame's cross origin script on my own server to get around the cross origin problem I had first with the xml file.

I do still hope that MAL will add these headers natively as it's of course faster to retrieve the file directly.

More topics from this board

» Why does MAL not support catbox.moe image links?

vasipi4946 - Yesterday

1 by traed »»
6 hours ago

» Got 502 Bad Gateway trying to create topic in Support

vasipi4946 - Yesterday

0 by vasipi4946 »»
Yesterday, 3:00 PM

Sticky: » Inactive Username Request Thread ( 1 2 3 4 5 ... Last Page )

Kineta - Sep 21, 2015

3366 by Midoriya_lzuku »»
Yesterday, 2:57 PM

» Invalid ID provided.

Zagafon - Sep 10, 2016

2 by Kitsunes97 »»
Yesterday, 9:24 AM

» Sort your list by member count/poularity?

paperkitten - Jun 17, 2010

1 by abdallah929 »»
Yesterday, 7:58 AM
It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login