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

Handle requests w/leading slashes throughout api for hosts with faraday configured url prefixes #112

Closed
wants to merge 1 commit into from

Conversation

alp06h
Copy link

@alp06h alp06h commented Apr 24, 2016

Issue is articulated here: lostisland/faraday#293

Issue:
conn = Faraday.new(:url => 'http://example.com/api')
conn.get '/index' #=> GET http://example.com/index

Solution:
conn.get 'index' (remove leading slash)

Example in discourse_api get('categories.json', params) instead of get('/categories.json')

In most cases clients will not experience this as I assume requests from domain ('http://example.com/') would be desired. However, if that is not the case faraday seems to strip url prefix when request has a leading slash.

I altered client.rb in a way that this won't impact any existing discourse_api users, but will not allow the ability to bypass this faraday quirk if they pass fourth argument upon initialization.

@oblakeerickson
Copy link
Member

Thank you for spending time on this PR, but I don't think this is something I really want to merge in.

99.9% of discourse installs all use a subdomain instead of inside of a folder off of the domain:

https://meta.discourse.org/t/can-discourse-run-in-a-folder-like-example-com-forum/18303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants