-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: try to simplify reproduction for #411
- Loading branch information
Showing
4 changed files
with
35 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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,6 +1,4 @@ | ||
export default (req, res) => { | ||
const reqValue = (new URLSearchParams(req.headers.cookie || '').get('mycookie') || '').split(';')[0].trim() | ||
const newValue = Math.round(Math.random() * 1000) + '' | ||
res.setHeader('Set-Cookie', `mycookie=${newValue}; path=/`) | ||
res.end(JSON.stringify([reqValue, newValue], null, 2)) | ||
const reqCookie = (new URLSearchParams(req.headers.cookie || '').get('mycookie') || '').split(';')[0].trim() | ||
res.end(reqCookie || '') | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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> |