Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tryfiles #15

Merged
merged 4 commits into from Apr 11, 2021
Merged

feat: add tryfiles #15

merged 4 commits into from Apr 11, 2021

Conversation

1lann
Copy link
Member

@1lann 1lann commented Apr 11, 2021

This PR adds a tryfiles directive to make it easier to serve compiled static content (React, Vue, etc.) for single page/progressive web apps or whatever you call them.

The default configuration (i.e. you only specify tryfiles and nothing else) looks like this:

# files to try in order
tryfiles {path} index.html index.htm index.txt default.html default.htm default.txt {
    # specify paths to exclude from this rule
    except /.well-known {cfg.addr.path}/.well-known
    # specify path prefixes to strip before trying to find them on the filesystem.
    without {cfg.addr.path}
}

where {cfg.addr.path} refers to the configured host's path if it is hosted on a subpath. For example:

chuie.io/example {
    # server config
}

# {cfg.addr.path} == "/example"

I also fixed some annoying bullshit like how the built in handler would redirect index.html permanently??? which imo is kinda ass. Now it doesn't attempt to redirect index.html at all, and it will only use temporary redirects.

@Lustyn @emmachase lmk what you think and if this covers your/all needs

Resolves #10

@1lann 1lann merged commit 903408c into master Apr 11, 2021
@emmachase
Copy link
Member

Looks great

@Lustyn Lustyn deleted the 1lann/try_files branch January 29, 2022 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backport try_files directive
2 participants