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

RACK_BASE_URI and delegating to Sinatra/Rack #1532

Closed
amadanmath opened this issue Dec 26, 2013 · 5 comments
Closed

RACK_BASE_URI and delegating to Sinatra/Rack #1532

amadanmath opened this issue Dec 26, 2013 · 5 comments

Comments

@amadanmath
Copy link

I am proxying my Padrino application from http://example.com/my_app/ to http://example.com:5000/:

<Location /my_app/>
    ProxyPass http://localhost:5000/
    ProxyPassReverse http://localhost:5000/
</Location>

and over there, I'm running Padrino in Puma, with RACK_BASE_URI set to /my_app.

If I'm using Padrino's new URL generation, all is fine (assuming get :test is defined):

url :test
# => /my_app/test
absolute_url :test
# => http://example.com/my_app/test

But in some circumstances, things are left to Sinatra or Rack, neither of which knows anything about RACK_BASE_URI:

url '/test'
# => /test
absolute_url '/test'
# => http://example.com/test
request.url
# => /test

(I wanted to get the URL to files within public which were not under stylesheets, javascripts or images, and thus not reachable by asset_path. I made a workaround with #{ url :index }/my_data, but it is hardly elegant.)


Another place I found (as much as I could see) is store_location! from padrino-admin: it just uses SCRIPT_URI, which will be the local /protected, and not /my_app/protected, which makes redirect_back_or_default hit the wrong location. (Maybe this should be a new issue?)

Anyway, if I am doing something wrong, I shall appreciate the feedback, since I could not find much documentation on this.

@ujifgc
Copy link
Member

ujifgc commented Dec 26, 2013

Could you try asset_path(nil, 'path/to/asset') ans tell if that's what you want?

@amadanmath
Copy link
Author

Oh, nil is allowed? Interesting undocumented fact.

asset_path :, 'my_data'
# => /my_app/my_data?1388045670

Thank you.

So that kind-of solves one of my problems. (It also appends the timestamp, without the option to switch it off; since my asset is static and unlikely to change, and allowing caching would make sense, a pure url would be better.)

The fact remains that url is inconsistent between simple and Padrino-style routes, and that store_location is remembering the wrong thing.

@ujifgc
Copy link
Member

ujifgc commented Dec 26, 2013

I will fix and document it soon.

I assume you are aware of disable :asset_stamp and want an option for asset_path to disable time-stamping of specific files, right?

As for url and store_location, please create new issue. These are unrelated to asset_path.

@ujifgc ujifgc closed this as completed in 9a13a5d Dec 26, 2013
@amadanmath
Copy link
Author

I will fix and document it soon.

Thank you, the patch makes sense.

I assume you are aware of disable :asset_stamp and want an option for asset_path to disable time-stamping of specific files, right?

Actually, I was not, thank you for that as well. I am a newcomer to Padrino, don't know all the ins and outs yet. Coincidentally, is there a central list of all the options? I find Padrino nice to work with, but I struggle with documentation.

As for url and store_location, please create new issue. These are unrelated to asset_path.

I'd rather say that asset_path was unrelated to this issue (I only mentioned it in parentheses as a workaround for what actually bugged me: inconsistency in handling RACK_BASE_URI); but since the root cause as well as the fix for url, store_location! and request_url are all different, they probably should be split up.

@ujifgc
Copy link
Member

ujifgc commented Dec 27, 2013

Coincidentally, is there a central list of all the options? I find Padrino nice to work with, but I struggle with documentation.

Yeah, there should be a list. The closest thing to it is app/app.rb generated with project, but it's not complete.

Ortuna pushed a commit to Ortuna/padrino-framework that referenced this issue Jan 17, 2014
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

No branches or pull requests

2 participants