Skip to content
This repository was archived by the owner on Jul 10, 2019. It is now read-only.

Commit 6cdcf61

Browse files
committed
feat: add /example/server-side-set-cookie.vue
1 parent 9c341c0 commit 6cdcf61

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/pages/example/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ section
6363
nuxt-link(to='/example/audio', no-prefetch) audio
6464
p
6565
nuxt-link(to='/example/video', no-prefetch) video
66+
p
67+
nuxt-link(to='/example/server-side-set-cookie', no-prefetch) server-side-set-cookie
6668
</template>
6769

6870
<script lang="ts">
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template lang="pug">
2+
section
3+
h1.title
4+
| server-side-set-cookie
5+
</template>
6+
7+
<script lang="ts">
8+
import { Component, Vue } from 'nuxt-property-decorator'
9+
import { AxiosRequestConfig } from 'axios'
10+
11+
@Component
12+
export default class ServerSideSetCookie extends Vue {
13+
public async mounted() {
14+
await this.$axios.$post(
15+
'http://localhost:5000/set-cookie',
16+
{
17+
token: 'hoge'
18+
},
19+
{
20+
// withCredentials をつけることで XHR 時に Set-Cookie を許可できる
21+
withCredentials: true
22+
} as AxiosRequestConfig
23+
)
24+
25+
// const xhr = new XMLHttpRequest()
26+
// xhr.open('POST', 'http://localhost:5000/set-cookie', true)
27+
// xhr.withCredentials = true
28+
// xhr.send('token=bar')
29+
}
30+
31+
public head() {
32+
return {
33+
title: 'server-side-set-cookie'
34+
}
35+
}
36+
}
37+
</script>
38+
39+
<style lang="scss" scoped>
40+
h2 {
41+
color: crimson;
42+
}
43+
</style>

0 commit comments

Comments
 (0)