Skip to content

Commit fc12285

Browse files
committed
Added response interceptor to transform 'x-xsrf-token' header into 'XSRF-TOKEN' cookie for cross-domain requests
1 parent a20a82c commit fc12285

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/client_vue_auth.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ <h2>Delete post {{ post.id }}</h2>
141141
withCredentials: true
142142
});
143143

144+
api.interceptors.response.use(function (response) {
145+
if (response.headers['x-xsrf-token']) {
146+
document.cookie = 'XSRF-TOKEN=' + response.headers['x-xsrf-token'] + '; path=/';
147+
}
148+
return response;
149+
});
150+
144151
function findpost (postId) {
145152
return posts[findpostKey(postId)];
146153
};

0 commit comments

Comments
 (0)