akatov / ember-bowser

:bowtie: ember wrapper for bowser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fastboot support

Redsandro opened this issue · comments

ember-bowser can play nice with fastboot support. It requires using the headers forwarded from the client to the fastboot server.

I'm not sure how these modules work so I'm afraid I cannot suggest a fully functional PR. But I think we can get fastboot if we choose the userAgent string before exporting bowser.

Detect fastboot and get the userAgent something like this, but adapted to a format that works for modules:

{
	fastboot: Ember.inject.service(),

	init() {
		let ua;
		if (this.get('fastboot').isFastBoot)
			ua = this.get('fastboot.request.headers').get('User-Agent');
		else
			ua = window.navigator.userAgent;
	}
}

But we need to somehow pass the argument to the export:

	if (!process.env.EMBER_CLI_FASTBOOT) {
		return bowser();
	else
		return bowser._detect(ua);