Open bantic opened 8 years ago
fyi I just hit this exact issue while playing around/learning fastboot. I wanted to simply render a page in my app directly within node w/o setting up express and discovered this error. If I pass in a stub e.g. app.visit('/mypage', {request: {}})
, then I get TypeError: Cannot read property 'cookie' of undefined
. Is it possible to render a page outside of an express server?
This might be better as an issue at ember-fastboot instead. Happy to move it over there if necessary.
In environments where the
Fastboot
app renderer/visiter visits a path and doesn't provide arequest
option, accessingthis.get('<fastbootService>.request')
will throw the error"cannot read property 'cookies' of undefined"
. E.g., if the app is visited via code that looks like this:And the ember app has code like the following, it will result in the error:
This is caused by the fact that there is no
{request}
passed as a second argument toapp.visit
:request
and uses it to construct aFastBootInfo
request
and never setsthis.request
propertyfastbootService.request
, the fastboot services builds aRequestObject
, passing it the "request" property that the FastbootInfo was instantiated with (which is undefined)RequestObject
reads thecookies
property on the undefined request, which leads to the errorThis problem is nonexistent when using the fastboot-express-middleware because it always passes the express
request
toapp.visit
.In certain use cases there may not be an express request to pass in to
app.visit
(for example, when using a lambda function to render the app).Should the
RequestObject
's constructor be changed to throw a meaningful error if it is accessed without a native/raw request that it can refer to? Or perhaps theFastboot
visit
method should warn when it is called without arequest
object?