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

Is it possible to add an allowFallback parameter to enable history mode? #397

Open
0x1af2aec8f957 opened this issue Dec 13, 2023 · 2 comments

Comments

@0x1af2aec8f957
Copy link

fileFound = _tryDefaultFile(fsPath, defaultDocument);

Is it possible to add an allowFallback parameter to enable history mode?

example: fileFound = _tryDefaultFile(allowFallback ? fileSystemPath : fsPath, defaultDocument);

Implement functionality similar to connect-history-api-fallback, which is important for integrating applications like Vue or React.

@kevmoo
Copy link
Member

kevmoo commented Dec 13, 2023

Would you explain a bit more?

@0x1af2aec8f957
Copy link
Author

@kevmoo Translated into the corresponding Nginx configuration:

location / {
  # root build_path;
  try_files $uri $uri/ /index.html;
}

Application scenario: When the requested file cannot be found, the top-level index.html file is always returned, which is important for providing web single-page applications.

Let me explain further through a practical scenario:

Now I have a static resources folder with the following structure

build_path
├── favicon.ico
├── index.html
├── static
   └── top_config.js

I hope that the mapping of the following paths can now be accessed through the createStaticHandler(build_path, defaultDocument: 'index.html') middleware:

Request path Mapping path
/ /index.html
/favicon.ico /favicon.ico
/static/top_config.js /static/top_config.js
/static /index.html
/static/other /index.html

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

No branches or pull requests

2 participants