r4ds / shinyslack

Integrate Slack and Shiny
Other
15 stars 3 forks source link

Can we detect site_url? #25

Closed jonthegeek closed 1 year ago

jonthegeek commented 2 years ago

I couldn't do it with Shiny (it sees the internal shinyapps.io URLs), but maybe I can more directly with javascript?

jonthegeek commented 2 years ago

Locally, request$SERVER_NAME works, but on shinyapps that doesn't work. BUT shinyapps has request$X-FORWARDED-HOST (the base url, such as r4dscommunity.shinyapps.io) and request$X-REDX-FRONTEND-NAME (the path including the application, such as r4dscommunity.shinyapps.io/scratch/). So check if those values exist and use them if they do, I think.

I should probably experiment with other deployment options and see what I see, or write about it in a vignette or help doc or something.

jonthegeek commented 2 years ago

Note: In each of the ui-returning functions, we should pull the site_url out of the request at the top (where we currently update the site_url), and then everything past that will function as normal.

jonthegeek commented 2 years ago

I re-learned (ha, it's in the comment from August 31 already) while digging through the request object for {scenes} that shinyapps sends this in the request: X-REDX-FRONTEND-NAME

That has the full url (minus query but including the name of the app) for the app on shinyapps.

I think we should probably check for that, then if it doesn't exist use SERVER_NAME, and fail gracefully.