nowfloats / kitsune-application-development-kit

a framework to build serverless web applications
https://www.getkitsune.com
Apache License 2.0
15 stars 6 forks source link

Support SPA through single entry point #16

Open varevarao opened 4 years ago

varevarao commented 4 years ago

Issue

Client side routing breaks in Single Page Applications built on Kitsune.

Expected Behaviour

If a particular link does not have an HTML file associated with it, the 'default' HTML should be returned instead, which will allow the client side router to handle routing based on client logic. This 'default' HTML could either be based on the HTTP status (200.html), or a predefined named file.

More Information

Single Page Applications with client side routing have a requirement of returning the same HTML file irrespective of path, in order to work correctly.

Currently Kitsune applications offer the option to use k-dl (Kit-dynamic link) in order to support such a use case,
For example,

<head k-dl="/path/with/[[variable-slug]]">
<!-- OR -->
<head k-dl="/[[dynamic]]/[[slugs]]/[[everywhere]]">

but this is limited, as the format and number of slugs in a link must be defined at build-time. While this is certainly possible for SPA's, it's a development, and maintenance nightmare for frameworks which are more JS heavy, than HTML (ex. React)

varevarao commented 4 years ago

surge.sh uses the file named 200.html, if found, as a fallback for any 404 issues to address this.