Skip to content

Test nginx configurations to work with History API on a Single-Page Application (SPA)

Notifications You must be signed in to change notification settings

Detoo/nginx-proxy-history-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test nginx configuration for HTML5 History API

The HTML5 History API enables manipulating browser history via scripts. Single-Page Application can utilize such API to allow routing/navigation in a way similar to the conventional multi-page website does but requires no page reload; however, when the user hits the refresh button, there is no way for the web server to draw the boundary between front-end and back-end routing. The Single-Page Application would not reload as expected.

This project demonstrates a solution by configuring nginx to serve all static assets while passing through all other routes to the application root(index.html) and let it handle the remainder route in the front-end. In the meantime, we can still configure nginx to reverse-proxy API calls.

Usage

docker-compose up
curl http://localhost
curl http://localhost/api/hello
curl http://localhost/test.txt
curl http://localhost/frontend/route/example

About

Test nginx configurations to work with History API on a Single-Page Application (SPA)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published