-
Notifications
You must be signed in to change notification settings - Fork 238
fix: preserve default headers with custom headers #452
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
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1509987
test: add failing test for #411
pi0 c0f1daf
test: try to simplify reproduction for #411
pi0 2dbcea5
Update test/fixture/pages/cookie.vue
pi0 254bbfc
fix: preserve default headers with custom headers
pi0 8a75b66
fix: override reqHeaders to config defaults
pi0 0cc3f62
test: update tests
pi0 47afb06
simplify fix
pi0 97c477f
update tests
pi0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export default (req, res) => { | ||
| const reqCookie = (new URLSearchParams(req.headers.cookie || '').get('mycookie') || '').split(';')[0].trim() | ||
| res.end(reqCookie || '') | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| export default async (req, res) => { | ||
| const query = new URL(req.url, 'http://localhost:3000').query | ||
| if (query && query.delay) { | ||
| await sleep(query.delay) | ||
| } | ||
|
|
||
| res.end(JSON.stringify({ | ||
| url: req.url, | ||
| method: req.method | ||
| })) | ||
| } | ||
|
|
||
| function sleep (ms) { | ||
| return new Promise((resolve) => { | ||
| setTimeout(resolve, ms) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,35 @@ | ||
| <template> | ||
| <div> | ||
| there should be no loading bar left over: | ||
| <button @click="test">Fake Request</button> | ||
| <button @click="test"> | ||
| Fake Request | ||
| </button> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| methods: { | ||
| test() { | ||
| const source = this.$axios.CancelToken.source(); | ||
| test () { | ||
| const source = this.$axios.CancelToken.source() | ||
| this.$axios | ||
| .$post( | ||
| "http://localhost:3000/test_api/foo/bar?delay=1000", | ||
| { data: "test" }, | ||
| 'http://localhost:3000/api/test/foo/bar?delay=1000', | ||
| { data: 'test' }, | ||
| { | ||
| cancelToken: source.token, | ||
| cancelToken: source.token | ||
| } | ||
| ) | ||
| .catch((err) => { | ||
| if (this.$axios.isCancel(err)) { | ||
| console.log("request canceled"); | ||
| console.log('request canceled') | ||
| } | ||
| }); | ||
| }) | ||
|
|
||
| setTimeout(function () { | ||
| source.cancel(); | ||
| }, 500); | ||
| }, | ||
| }, | ||
| }; | ||
| source.cancel() | ||
| }, 500) | ||
| } | ||
| } | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <template> | ||
| <div> | ||
| <pre style="display: none">_req:{{ reqCookie }}</pre> | ||
| <p>Pass: {{ pass }}</p> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| async asyncData ({ app }) { | ||
| const reqCookie = (await app.$axios.$get('/cookie')) + '' | ||
| return { | ||
| reqCookie | ||
| } | ||
| }, | ||
| data () { | ||
| return { | ||
| pass: '?' | ||
| } | ||
| }, | ||
| async mounted () { | ||
| const randomValue = Math.round(Math.random() * 1000) + '' | ||
| document.cookie = `mycookie=${randomValue}; path=/` | ||
|
|
||
| // Render page with server-side, expecting to be rendered with same new cookie | ||
| const html = await this.$axios.$get(window.location.href) | ||
| const m = html.match(/_req:(\w+)/) | ||
| const profifiedSSRCookie = m && m[1] | ||
|
|
||
| this.pass = randomValue === profifiedSSRCookie | ||
| } | ||
| } | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.