Sunday, January 15, 2017

Day 13

Current Project: Random Quote Machine
Today's Progress: I already made the RQM work, but a nagging question remained. What if CORS doesn't work, either because it isn't supported by an older browsers or the server simply doesn't allow a cross-origin request (i.e. the header 'Access-Control-Allow-Origin' isn't properly set server-side)? So I toyed around with different approaches to circumvent the same-origin policy (also played with jQuery methods and their parameters), like JSONP or a regular Pen as a rescource. Both worked pretty well, that is I got at least a successful respone from the server which I could console.log (didn't build the full app each time).

Important note: If you want to test my RQMs, make sure that your URL uses the proper protocol ( Since the APIs I found both use 'http' but the application is run on codepen using 'https' by default, it will result in an error, like this:

"Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '[orderby]=rand&filter[posts_per_page]=1&_=1484558978794'. This request has been blocked; the content must be served over HTTPS."

By the way, using the proxy '' as a workaround didn't work at all (see this article). Maybe you got an idea? Please share it in the comment section below (or any other thougths)!
Thoughts: That's it for now. I'll continue working on my layout, since it still looks pretty shitty and maybe trying to refactor some of my code by looking at some JS of other campers' RQM code.
My plans for tomorrow:

Follow my Pens on Codepen
Follow me on FreeCodeCamp

No comments:

Post a Comment