Plumier provided functionality to serve static file using koa-send middleware
Serve static files is optional, you can enable this functionality by install
@plumier/serve-static and plug
ServeStaticFacility into Plumier application
root directory provided it will automatically search for directory named
www in the same level with the application.
You can serve multiple folder by specifying multiple facility
Its possible to serve single file from controller by using
History Api Fallback help SPA application which commonly handle navigation using History Api. Its become problem when user hitting refresh button in the middle of navigation or if user bookmark the page because it will result in 404.
@route.historyApiFallback() decorator to automatically redirect all the browser request (API or file request can be detected) into the specific controller action. Internally it detects the request
Accept header to guess if the request comes from a browser or an API call.
Keep in mind that
@route.historyApiFallback() require the
ServeStaticFacility enabled on the Plumier application.
Example above showing that you host the SPA html built by
@vue/cli as the root url
@route.historyApiFallback() will automatically redirect all browser request into the root url
/ with exception:
- Requested url doesn't have any appropriate controller / handler
- Requested url is not a static file serve
- Requested url is not an API call