Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access Atom feeds from Javascript (CORS issue) #6329

Open
1 of 2 tasks
CaptainSpam opened this issue Jan 22, 2018 · 4 comments
Open
1 of 2 tasks

Cannot access Atom feeds from Javascript (CORS issue) #6329

CaptainSpam opened this issue Jan 22, 2018 · 4 comments
Labels
bug Something isn't working

Comments

@CaptainSpam
Copy link

I'm working on a simple StatusNet (GNU Social, Mastodon, etc) Javascript widget, so one could, for instance, embed a StatusNet feed into a website. It's mostly for my own use on my own server, but I'm trying to make it as useful as possible for people with other setups than I use.

The way I have it set up, you give the widget an Atom feed, it downloads it, and it formats the posts. This works fine on my GNU Social setup, but it fails on any Mastodon instance I try it on, owing to the Atom feeds not being sent with Access-Control-Allow-Origin headers. Javascript refuses to do anything with that for (very good) security reasons.

I'll admit I haven't done much work involving Javascript reading data from remote APIs like this, so this may seem like a naive question, but is there a specific reason why Mastodon doesn't return that header when fetching a user's Atom feed? And if not, would it be possible to update it to do so?

I'm not currently running a Mastodon instance; this is just from the perspective of a developer reading data from a feed.


  • I searched or browsed the repo’s other issues to ensure this is not a duplicate.
  • This bug happens on a tagged release and not on master (If you're a user, don't worry about this).
@nightpool
Copy link
Member

nightpool commented Jan 22, 2018 via email

@unarist
Copy link
Contributor

unarist commented Jan 23, 2018

Note that browsers won't send credentials (i.e. cookies) on cross-origin requests unless the server allowed explicitly via exposes Access-Control-Allow-Credentials header. Also we've already allowed basic CORS on some routes including REST APIs.

https://github.com/tootsuite/mastodon/blob/69f13e7bca90f4855e05a49dd69bba66f843134a/config/application.rb#L81-L88

@Gargron Gargron added the bug Something isn't working label Oct 20, 2018
@vitalyster
Copy link

Same issue for ActivityPub endpoints

@ghost
Copy link

ghost commented Nov 2, 2018

Same issue for the status embed endpoint.

For example: https://fosstodon.org/@measlytwerp/100568808235949213/embed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants