Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.6.0] req.headers.origin undefined in CLI mode #601

Closed
hoIIer opened this issue Feb 8, 2022 · 0 comments · Fixed by #819
Closed

[0.6.0] req.headers.origin undefined in CLI mode #601

hoIIer opened this issue Feb 8, 2022 · 0 comments · Fixed by #819

Comments

@hoIIer
Copy link

hoIIer commented Feb 8, 2022

version 0.6.0
ember-auto-import: 2.4.0
ember 3.28.0

When I run my fastboot test in browser mode it passes:

image

When I run it in cli mode it fails with:

Error: Ember CLI FastBoot Testing: We were unable to render /p/abc123. Is your test suite blocking or intercepting HTTP requests

Noticing it's missing the x-fastboot-testing header

{
  connection: 'keep-alive',
  'content-length': '22',
  'content-type': 'text/html; charset=utf-8',
  date: 'Tue, 08 Feb 2022 01:10:53 GMT',
  etag: '\\16-Iz+hV1iVsvp6pCFWupm+jyvhDK8\\',
  'keep-alive': 'timeout=5',
  vary: 'Accept-Encoding',
  'x-powered-by': 'Express'
}

Any suggestions on what could cause this?

edit 1

Was able to determine that it fails due to missing request origin header in cli mode at this line:
https://github.com/embermap/ember-cli-fastboot-testing/blob/v0.6.0/lib/helpers.js#L42

We need to use a fallback value for CLI mode where req.headers.origin is undefined:

const parsed = new URL(urlToVisit, req.headers.origin);

e.g.

 const origin = req.headers.origin || 'http://localhost';
 const parsed = new URL(urlToVisit, origin);
@hoIIer hoIIer changed the title Test passes in browser mode only Test passes in browser mode only 0.6.0 Feb 8, 2022
@hoIIer hoIIer changed the title Test passes in browser mode only 0.6.0 [0.6.0] req.headers.origin undefined in CLI mode Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant