Skip to content

File not found when trying to access static files behind a directory symlink #3073

@MightyDuke

Description

@MightyDuke

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Trying to get a static file behind a directory symlink will return a 404 error, despite being able to browse the directory when directory_view=True is used.

Code snippet

app.static("/static", "directory_with_a_directory_symlink/", directory_view=True)

Expected Behavior

Serve the file, don't return 404.

How do you run Sanic?

As a module

Operating System

Linux

Sanic Version

25.3.0

Additional context

For example, have a directory structure like this:

.
├── app.py
├── static
│   ├── myfiles -> (symlink to ../myfiles/)
└── myfiles
    ├── myfile1.txt
    ├── myfile2.txt
    └── myfile3.txt

Have Sanic serve the static directory:

app.static("/", "static/", directory_view=True)

When you now run the app and go to /myfiles you can see the files in the myfiles directory, however when you click on any of the files 404 Not Found error is returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions