Skip to content

[Feature Request] Static Mode With Catch-all Capability #94

Open
@Janaka-Steph

Description

This issue is a feature request asking to add a catch-all capability to the static mode.
The static server should redirect every possible url pointed to the function to the root path.
Example: http:127.0.0.1:8080/function/hello/subpath -> http:127.0.0.1:8080/function/hello

In Nginx, this is accomplished with the try_files directive.
https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/#trying-several-options

Current Behaviour

Currently, requesting any function subpath, i.e http:127.0.0.1:8080/function/hello/subpath, will return a 404 error.

Context

This capability is mandatory in the context of Single Page Applications, like React.js apps.
Using Hash History adding # in the URL brings other issues and is not a valid solution for professional modern web applications.
A Single Page Application technically only have a single index.html, and a server should redirect every possible url pointed to the domain at this index.html located at the root.

In Nginx, we implement a catch-all rule for SPA like so:

location / {
    try_files  $uri  $uri/  index.html;
}

Link to your project or a code example to reproduce issue

Minimal React.js Single Page Application packaged for OpenFaaS with the dockerfile template and the watchdog in static mode: https://github.com/Janaka-Steph/react-spa-openfaas

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions