ember-fastboot / ember-fastboot/fastboot-app-server

Feature: Conditionally use fastbootMiddleware

Open
#99 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
140
Forks
70
PR merge metrics
No merged PRs in 30d

Description

In most of the use cases that I use Fastboot, its mainly because of the SEO and OG tags (consumed by bots), not for the actual render of something to the end user, while its nice and rehydratation make it even better, sometimes I prefer the instant loading feel (getting fastboot off of the crital path) with an appshell for loading screen, this can be accomplish by using fastboot middleware conditionally from reading user-agent string to detect if its a bot or a human. I got it working by adding this middleware in Worker.js for ExpressServer, since the code always expects a middleware, I condiotionally run the fastbootmiddleware or just an empty one, using `express-conditional-middleware`

```
app.use(
conditional(
(req, res, next) => { return this.isBot(req.get('user-agent')) },
fastbootMiddleware,
(req, res, next) => { next() }
)
)
```
I think this feature could be exposed as config as boolean, please let me know your thoughts

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.