Production Deployment : Blocked request. To allow this host, add `server.allowedHosts` in vite.config.js.
Hi @wch @schloerke @icarusz
## Describe the problem
We are building a web application using Rshiny and have reticulate being called (for some Python functions inside R). The docker build file is shared for your reference. The build is working fine perfectly in IP port , however we get error while using private DNS url for that IP Port.
Error Information:
Blocked request. This host ("stgvfrejectreason.chola.murugappa.com") is not allowed.
To allow this host, add "stgvfrejectreason.chola.murugappa.com" to `server.allowedHosts` in vite.config.js.
Work arounds - Failed
options(bslib.vite = FALSE)
Sys.setenv(VITE_ALLOWED_HOSTS = "stgvfrejectreason.chola.murugappa.com")
```r
# Use official R base image
--
FROM r-base:4.2.3
# --------------------------------------------------
# Install system dependencies
# --------------------------------------------------
RUN apt-get update && apt-get install -y \
curl \
gnupg \
unixodbc \
unixodbc-dev \
libcurl4-openssl-dev \
libfontconfig1-dev \
libfreetype6-dev \
libssl-dev \
libxml2-dev \
libpq-dev \
libmariadb-dev \
libsqlite3-dev \
apt-transport-https \
ca-certificates \
lsb-release \
libhiredis-dev \
libsodium-dev \
cmake \
libv8-dev \
wget \
&& rm -rf /var/lib/apt/lists/*
# --------------------------------------------------
# Install CRAN packages (your stack + devtools deps)
# --------------------------------------------------
RUN R -e "install.packages(c( 'shiny', 'bslib', 'readxl', 'dplyr', 'glue','reticulate',
'jsonlite', 'curl', 'openssl','gemini.R', 'httr', 'httr2', \
'remotes', 'devtools','future','promises','future.apply'\
), repos='https://cran.rstudio.com/')"
RUN R -e "install.packages(c('jose'),repos ='https://cran.rstudio.com/')"
RUN R -e "install.packages(c('R.utils','R.oo','R.methodsS3'),repos ='https://cran.rstudio.com/')"
# --------------------------------------------------
# Install specific mongolite version (SOURCE BUILD)
# --------------------------------------------------
RUN R -e "remotes::install_version('mongolite', version = '2.3.1', repos='https://cran.rstudio.com/', upgrade = 'never')"
# --------------------------------------------------
# Configure Python environment for reticulate
# --------------------------------------------------
# Set Python environment variables
ENV RETICULATE_PYTHON=/usr/bin/python3
ENV PYTHONPATH=/usr/local/lib/python3.9/site-packages:/usr/lib/python3/dist-packages
RUN python3 -m pip install --no-cache-dir numpy --break-system-packages
RUN python3 -m pip install --no-cache-dir pandas --break-system-packages
RUN python3 -m pip install --no-cache-dir clickhouse-connect --break-system-packages
# Verify Python installation
RUN python3 -c "import numpy; print('numpy installed successfully')"
# --------------------------------------------------
# Clean up
# --------------------------------------------------
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# --------------------------------------------------
# Configure reticulate in R environment
# --------------------------------------------------
RUN R -e "library(reticulate); use_python('/usr/bin/python3', required = TRUE); py_config()"
# --------------------------------------------------
# App setup
# --------------------------------------------------
RUN mkdir /vf_rejection
RUN mkdir /vf_rejection/token
RUN mkdir /vf_rejection/utl
RUN mkdir /vf_rejection/src
RUN mkdir /vf_rejection/reference_files
RUN mkdir /vf_rejection/folder_output
# Copy all project files
COPY . /vf_rejection/
COPY . /vf_rejection/token
COPY . /vf_rejection/utl
COPY . /vf_rejection/src
COPY . /vf_rejection/reference_files
WORKDIR /vf_rejection
# Permissions (optional if already correct)
RUN chmod 755 -R /vf_rejection
# Expose plumber API port
EXPOSE 8080
# --------------------------------------------------
# Start the main R script
# --------------------------------------------------
CMD ["Rscript", "/vf_rejection/app.R"]
```
Thanks
Arun
关闭于 2025-12-16 2 条评论