-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Enable Fastboot relative URL #143
Conversation
@mike-north My local ember-cli-fastboot server doesn't really give me |
Passed |
I think it should be noted that this approach doesn't seem to work for either absolute or relative URLs when using Fastboot with Prember. By that I mean when I use the PR from @rwwagner90 #128 then using a fetch in a model hook like this: model() {
return fetch('/assets/some.json').then(res => {
return res.json();
});
} works with Fastboot, but gives an error when using with Prember.
However, this seems to be able to be resolved by including the absolute URL (which isn't ideal but is a workable solution for the few model() {
let path = '/assets/some.json';
if (this.fastboot.isFastBoot) {
const headers = this.fastboot.request.headers;
let host = headers.get('host');
path = `http://${host}${path}`;
}
return fetch(path).then(res => {
return res.json();
});
} Although this isn't ideal it does work and allows for Prember builds. Whereas this PR does not—there is still the same error message as before even after including this code. I hope others agree that Prember is an increasingly important use case for Fastboot and that a solution which doesn't seem to be compatible with it is inferior to one which does. If this gets merged as is then I'm concerned that there will still be an issue for the majority of users. Maybe the fix is needed on the Prember side but I thought it was worth making others aware of this. |
Hi @chrism, can you share a reproduction repo? |
@xg-wang @chrism my site uses prember, and you can feel free to test it there https://github.com/shipshapecode/shipshape.io Is there a reason we cannot use the code from my PR? |
@rwwagner90 That PR only allows relative URLs for adapters, a pure
before making a @chrism Would be very helpful if you can create a small repro for your code snippet with Prember setup. |
@xg-wang as I said above, please use my repo for prember testing. https://github.com/shipshapecode/shipshape.io |
@rwwagner90 Yea I will. I want to use both your app and his for Prember testing. A minimal setup can be easier to set debugger to play around with. I can try a get one but since @chrism seems already have a repro we can just use his. |
@rwwagner90 Do you have a branch that's breaking bc relative URL for shipshape.io? |
Hi, I’m sorry I haven’t yet pushed the example repo. It’s been quite time consuming to create the most simple illustration of where one branch works and the other doesn’t. I’m at a conference this week but I’ll find some time on Friday, at the latest. |
@rwwagner90 🔥
@chrism Can you test this branch when you are free? |
@xg-wang nice! Glad it's working 😄 . I can test things out and poke around the app a bit this weekend. |
Hi @xg-wang I've just used this branch instead of @rwwagner90's and it works with my project too. 👍 🎉 😄 I'll still try to finish the test repos I'm working on this weekend to show the most simple use cases as I think ideally maybe one day they could perhaps even be incorporated into some testing. Thanks to both you and @rwwagner90 for getting this working. |
define fetch module at instance-initializers to get request info
- Prember is not sending protocol, need to check "undefined:" - node-fetch 2.3 has AbortController support - Fix issue when fetch(request) instead of fetch(url, options)
@@ -40,6 +40,8 @@ | |||
"ember-cli": "~3.0.2", | |||
"ember-cli-dependency-checker": "^3.0.0", | |||
"ember-cli-htmlbars": "^3.0.1", | |||
"ember-cli-eslint": "^4.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xg-wang why did you add this again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be there, I must did a bad rebase.
This upgrades ember-fetch to `^6.2.0`. The primary reason for upgrading are the fixes for: - Usage of ember-fetch in monorepos: ember-cli/ember-fetch#165 https://github.com/ember-cli/ember-fetch/releases/tag/v6.1.1 - Enabling Fastboot relative URLs: ember-cli/ember-fetch#143 https://github.com/ember-cli/ember-fetch/releases/tag/v6.2.0
This PR overrides #128, fixes #138 #110
Implementation stolen from https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/fastboot/initializers/ajax.js
Also upgrade node-fetch to 2.3, which has the abort support
TODO: