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

JSONP support #47

Closed
rdebeasi opened this issue Oct 25, 2013 · 4 comments
Closed

JSONP support #47

rdebeasi opened this issue Oct 25, 2013 · 4 comments

Comments

@rdebeasi
Copy link

It would be great if haste-server supported JSONP, so that JavaScript-based clients could interact with it.

Hastebin rocks - thanks for creating this project!

seejohnrun added a commit that referenced this issue Dec 4, 2013
@seejohnrun
Copy link
Contributor

Have this implemented off in the jsonp branch - let me know if this fits the bill
Thanks for the feature request

@rdebeasi
Copy link
Author

rdebeasi commented Dec 8, 2013

That's exciting news - thanks very much!

I'm having trouble getting this feature to work with my JavaScript "client." When I try to submit data via JSONP, I get back the HTML for Hastebin rather than JSON containing a key.

As a test, I tried a submitting form to my local instance of Hastebin normally, with no JavaScript. When I used POST to send the data, I received a key as expected. When I used GET to send the data, my browser navigated to http://0.0.0.0:7777/documents/?data=jhklhkljh, which gave me the HTML for Hastebin.

So, it sounds like I'd need to use POST instead of GET. The problem is that JSONP works only with GET, not POST. Additionally, GET is probably not well-suited for submitting large blocks of code.

Any thoughts on what might be going on here? Am I misunderstanding how to interact with haste-server? Should I be using CORS instead of JSONP? If it helps, you can see my extremely basic "client" code at https://github.com/rdebeasi/post-haste.

Thanks again for your help, and my apologies if the JSONP suggestion turns out to be a bad idea.

@seejohnrun
Copy link
Contributor

Ahh I think I may have misunderstood the original goal.
The branch will allow retrieval of haste data for a given key via JSONP

I'm a bit wary to take in data for hastes over GET.

Maybe it's an idea to offer a library you can use on your site - which is hosted on the hastebin domain to create documents (similar to the approach taken with stripe.js) which would allow for CORS

Do you have some more details on your use case? There's always the ability have a smaller server that created the pastes but that may be too heavyweight

@seejohnrun
Copy link
Contributor

Please re-open if any other questions!

@IJustDev IJustDev mentioned this issue Oct 15, 2020
IJustDev added a commit to IJustDev/haste-server that referenced this issue Oct 15, 2020
Javascript browser clients can now use hastebin.

Fix toptal#352 Fix toptal#47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants