It seems that for shiny > 1.2.0, the mime package is no longer being used to infer the content type of certain resources. Specifically, I am loading some html that requests a .jsonp file, whose type gets guessed to application/octet-stream. (parroting the devops people here) A security setting to prevent type sniffing attacks cause this request to fail.
With 1.2.0, the mime package is used to guess the type, and it correctly sets the type to application/javascript. Is there a way to shiny > 1.2.0 to use the mime packages mimemap?
Attempt at a reprex, using a slightly modified version of this example :https://gist.github.com/hafen/ef69d752b08cb1fe005461e55bde24b4 shown below. runApp(), then open your browser developer tools network tab. Hit "Create Trelliscope Display". Watch for a request for a jsonp object. In 1.2.0, it will be application/javascript, with shiny > 1.2.0 it will be application/octet-stream.
library(shiny)
library(dplyr)
library(tidyr)
library(ggplot2)
library(trelliscopejs)
ui <- fixedPage(
title = "Test Shiny App with TrelliscopeJS",
fixedRow(
column(width = 4,
tags$br(),
selectInput("example",
label = "Choose Example", choices = c("example 1", "example 2")),
actionButton("make_trelliscope", "Create Trelliscope Display")
),
column(
width = 8,
# dimensions for trelliscopeOutput should be in units of "px"
trelliscopeOutput("trelliscope_out",
width = "800px", height = "800px")
)
)
)
server <- function(input, output, session) {
output$trelliscope_out <- renderTrelliscope({
if (input$make_trelliscope == 0) {
NULL
} else {
ex <- isolate(input$example)
if (ex == "example 1") {
x <- factor(LETTERS[1:4])
names(x) <- letters[1:4]
data_year_date <- data.frame(
year = structure(seq(1950, 1989, 1), class = "Date"),
var = rep(x, 10), y = seq(1, 200, 5))
# trelliscope displays must go in www/...
# also, can do self_contained = TRUE, but this is not advised
p <- ggplot(data_year_date, aes(year, y)) + geom_point() +
facet_trelliscope(~ var, path = "www/")
# if output is from using facet_trelliscope, need to print it
print(p)
} else if (ex == "example 2") {
mpg %>%
group_by(manufacturer, class) %>%
nest() %>%
mutate(
panel = map_plot(data, ~
qplot(cty, hwy, data = .) + xlab("cty") + ylab("hwy") +
xlim(7, 37) + ylim(9, 47) + theme_bw())) %>%
trelliscope(name = "tidy_gg", path = "www/",
nrow = 2, ncol = 2)
} else {
NULL
}
}
})
}
shinyApp(ui = ui, server = server)
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] trelliscopejs_0.2.6 ggplot2_3.3.3 tidyr_1.1.3 dplyr_1.0.5 shiny_1.6.0