ember-fastboot / ember-fastboot/ember-cli-fastboot
.html() works unexpectedly for redirects when rendering fastboot on a cdn using fastboot.visit()
- Dominant language
- JavaScript
- Stars
- 850
- Forks
- 161
- Avg merge
- 17h 45m
- Merged PRs (30d)
- 19
Description
I'm rendering a fastboot page on a cdn like so:
```
const res = await this.fastboot.visit(
this.request.url,
{request: this.request},
);
html = await res.html();
...
```
I have a route with nested child routes, and I want the index to redirect to the child like so:
```
this.route('foo', function() {
this.route('bar');
});
```
```
import Route from '@ember/routing/route';
export default class FooIndexRoute extends Route {
redirect() {
this.transitionTo('foo.bar');
}
}
```
When a user navigates directly to `mysite.com/foo`, fastboot hits [this line](https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/packages/fastboot/src/result.js#L40) and instead of rendering the redirected page, it returns an anchor link which exposes the cdn resource.
`
Redirecting to ${location}
`I was able to get around this using a small hack but wondering if we should include an optional param to `html()` that would tell fastboot to render the redirected page?
```
const res = await this.fastboot.visit(
this.request.url,
{request: this.request},
);
if (res.statusCode >= 300 && res.statusCode <= 399) {
// trick fastboot into thinking it was a successful request.
res._fastbootInfo.response.statusCode = 200;
}
// render the pages html.
html = await res.html();
```
Contributor guide
Assessment
This issue has not been assessed yet.