Skip to content

Commit c22da6e

Browse files
author
John Ratcliff
committed
Dev server forwards out of scope requests
When running a dev server and an app is mounted at a root URL other than `/`, it is possible for requests to make it to the fastboot server that do not have the `x-broccoli` header. Moving parsing of this header deeper into the request allows for these out of scope requests to be forwarded on.
1 parent 538adf8 commit c22da6e

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,13 @@ module.exports = {
306306
app.use((req, resp, next) => {
307307
const fastbootQueryParam = (req.query.hasOwnProperty('fastboot') && req.query.fastboot === 'false') ? false : true;
308308
const enableFastBootServe = !process.env.FASTBOOT_DISABLED && fastbootQueryParam;
309-
const broccoliHeader = req.headers['x-broccoli'];
310-
const outputPath = broccoliHeader['outputPath'];
311309

312310
if (req.serveUrl && enableFastBootServe) {
313311
// if it is a base page request, then have fastboot serve the base page
314312
if (!this.fastboot) {
313+
const broccoliHeader = req.headers['x-broccoli'];
314+
const outputPath = broccoliHeader['outputPath'];
315+
315316
// TODO(future): make this configurable for allowing apps to pass sandboxGlobals
316317
// and custom sandbox class
317318
this.ui.writeLine(chalk.green('App is being served by FastBoot'));

test/root-url-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ describe('rootUrl acceptance', function() {
4040
});
4141
});
4242

43+
it('Out of scope requests', function() {
44+
return request({
45+
url: 'http://localhost:49741/foo-bar/',
46+
headers: {
47+
'Accept': 'text/html'
48+
}
49+
})
50+
.then(function(response) {
51+
expect(response.statusCode).to.equal(404);
52+
});
53+
});
54+
4355
it('with fastboot query parameter turned on', function() {
4456
return request({
4557
url: 'http://localhost:49741/my-root/?fastboot=true',

0 commit comments

Comments
 (0)