Bug #18244
closed
Added by Marilyn Weber over 1 year ago.
Updated over 1 year ago.
Description
Via ZD:
I am a librarian at the Graduate Center Library and I also work on the library website. Since a site we use for the purpose has gone down permanently, I am reimplementing an RSS feed reader to ingest the posts on our Commons site. I have run up against a CORS error, and the simplest solution would be to do as this page suggests: https://bionicteaching.com/allowing-cross-origin-access-to-wordpress-feeds/
Is that possible? It would be very helpful.
Thanks,
Steve
Stephen Zweibel
Digital Scholarship Librarian
- Status changed from New to Reporter Feedback
I'd be glad to explore a CORS exception for RSS feeds, but could I first get some more details? It would be helpful to know the specific Commons feed(s) that the third-party application is trying to ingest. And ideally, it would be great if I could see the URL where the ingesting will take place - eg, if it's a WordPress site with a widget that pulls in RSS items. That way, I could test the CORS headers myself.
We use GitHub Pages for our static site in order to not have to pay for a server.
Do you have the application built already, and hosted on GitHub Pages? I can certainly write my own small application to mimic what you're doing, but it would be easier if I could use yours.
Sure, the Pages site is: https://gc-library.github.io/Mina-Rees-library-site/
and the repo is: https://github.com/GC-Library/Mina-Rees-library-site
you can see the code in static/js/utils.js and the error can be seen in the console: Access to fetch at 'https://gclibrary.commons.gc.cuny.edu/category/blog/website-front-page/feed/?fsk=5c1146bca3512' from origin 'https://gc-library.github.io' 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 actually I tried this 'no-cors' mode and it didn't work.
Thanks,
Steve
Stephen Zweibel
Digital Scholarship Librarian
CUNY Graduate Center
________________________
From: Marilyn Weber (CUNY Academic Commons) <support@cunycommons.zendesk.com>
Sent: Thursday, May 18, 2023 12:50 PM
To: Stephen Zweibel <szweibel@gc.cuny.edu>
Subject: [CUNY Academic Commons] Re: Commons CORS Error
Thanks for providing this information. Rather than the wildcard header you suggested, I've introduced a specific exception for https://gc-library.github.io. For my reference, see the following in our root htaccess:
41 Header set Access-Control-Allow-Origin 'https://gc-library.github.io'
42 Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, User-Agent"
In my tests, the RSS importer at https://gc-library.github.io/Mina-Rees-library-site/ is now fetching items and logging them in the console.
- Target version set to 2.1.7
Steve Z confirms that this work. I think this ticket can be closed now.
- Status changed from Reporter Feedback to Resolved
Also available in: Atom
PDF