ember-fastboot / ember-fastboot/ember-cli-fastboot
No support for FastBoot context only configuration
- Dominant language
- JavaScript
- Stars
- 850
- Forks
- 161
- Avg merge
- 17h 45m
- Merged PRs (30d)
- 19
Description
There is no support for having different `config/environment` outputs for FastBoot vs browser in the build process (i.e. `fastboot.appConfig` in `dist/package.json` vs `dist/index.html`) even though Ember FastBoot App Server uses `fastboot.appConfig` from `package.json` exclusively.
## Senario
An application relies on an API. When running in the browser context the application calls the public endpoint as normal. However when running in a FastBoot context the application should call the (sensitive) internal endpoint to avoid a round trip outside.
## Unsuitable solutions
**Check for `isFastBoot` on the fastboot service**
While technically this would work, the internal endpoint would be leaked in the config meta tag in index.html
**Use a conditional include/macro/post-process**
Again, this would technically work, however this would very much be a work around and this problem is something that many people will have.
**`process.env.EMBER_CLI_FASTBOOT`**
This flag is not useful because "the EMBER_CLI_FASTBOOT environment variable is not set when the FastBoot build actually happens" – ember-cli-fastboot/lib/broccoli/fastboot-build.js#L126.
## Possible solutions
**Explicitly pass in a flag to config/environment**
This would require changes to Ember CLI and seems like a slippery slope
**`config/context`**
The output of `config/environment` and the context (browser | fastboot) could be passed to a context function to alter the config for the context.
**??**
Other options?
---
Not sure what the right move is here but willing to put some effort in to make it happen.
Contributor guide
Assessment
This issue has not been assessed yet.