I have an existing ember application. I am trying to make it fastboot compatible.
However, fastboot is unable to serve the page statically. After digging through the code, I found this snippet which is causing the issue.
if (broccoliHeader['url'] === req.serveUrl && enableFastBootServe) {
// if it is a base page request, then have fastboot serve the base page
if (!this.fastboot) {
// TODO(future): make this configurable for allowing apps to pass sandboxGlobals
// and custom sandbox class
this.ui.writeLine(chalk.green('App is being served by FastBoot'));
this.fastboot = new FastBoot({
distPath: outputPath
});
}
let fastbootMiddleware = FastBootExpressMiddleware({
fastboot: this.fastboot
});
fastbootMiddleware(req, resp, next);
} else {
// forward the request to the next middleware (example other assets, proxy etc)
next();
}
I have found that for my App, req.serveUrl is always undefined. Can anyone help me understand why that is the case and how to fix it.
Which ember-cli-fastboot version? Please take note of the breaking changes in the more recent versions, I’ve got mine in production pegged to 1.0.0-beta.19
Ok, then there might a little bit of learning for you to do first, but its not hard. fastboot-app-server just serves up an express middleware specifically tuned for ember apps. Check out all available req methods here Express 4.x - API Reference I think your issue is that the method req.serveUrl does not exist, try req.url instead.
@The_Don_Himself The code that I pasted in ember-cli-fastboot code. I don’t control it. I was trying to find the cause of my issue that fastboot wont work for my app
I was able to track down where req.serveUrl is set.
I found that the ember cli adds middleware in following cases.
locationType is set to ‘auto’ or ‘history’
Or
historySupportMiddlewar ENV is set
Since I am using proxy in my dev environment, i had locationType set to ‘hash’.
So I solved the issue by setting historySupportMiddleware to true for dev environment only
Thanks @The_Don_Himself for pointing me to the req documentation. When I saw that by default serveUrl does not exist, only then I thought of figuring out where it is getting set.