New files cannot be served in production mode
Describe the bug
When running in production mode (pc run --env prod) new files created/uploaded in .web/public folder cannot be accessed/visualized/downloaded. No matter if using pc.image or pc.link, the browser will throw a 404 error. Only the files that were present at compilation are accessible from the browser.
To Reproduce Steps to reproduce the behavior:
- Simply use the code from upload component in documentation:
import pynecone as pc
class State(pc.State):
"""The app state."""
# The image to show.
img: str
async def handle_upload(self, file: pc.UploadFile):
"""Handle the upload of a file.
Args:
file: The uploaded file.
"""
upload_data = await file.read()
outfile = f".web/public/{file.filename}"
# Save the file.
with open(outfile, "wb") as f:
f.write(upload_data)
# Update the img var.
self.img = file.filename
color = "rgb(107,99,246)"
def index():
"""The main view."""
return pc.vstack(
pc.upload(
pc.vstack(
pc.button(
"Select File",
color=color,
bg="white",
border=f"1px solid {color}",
),
pc.text(
"Drag and drop files here or click to select files"
),
),
border=f"1px dotted {color}",
padding="5em",
),
pc.button(
"Upload",
on_click=lambda: State.handle_upload(
pc.upload_files()
),
),
pc.image(src=State.img),
padding="5em",
)
# Add state and page to the app.
app = pc.App(state=State)
app.add_page(index, title="Upload")
app.compile()
- run command
pc run --env prod - upload an image
Expected behavior Image should show up on the page.
Screenshots

Specifics:
- Python Version: 3.10.4
- Pynecone Version: 0.1.24
- OS: Ubuntu 20.04.6 LTS
Additional context
In that context, the image is uploaded, as it shows up in .web/public/ folder.
Image displaying (or more generally new file serving) works perfectly when using development mode pc run --env dev
This is because hot loading works only development. If you want you can make pr with ease!!
The new recommended way is to use rx.upload_dir which will allow files to be added dynamically: https://reflex.dev/docs/library/forms/upload/