0
0
Fork 0
This commit is contained in:
xeltica 2021-09-01 21:32:45 +09:00
parent 347a5680ae
commit ba40952a09
7 changed files with 99 additions and 49 deletions

View file

@ -2,4 +2,20 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { App } from './App';
ReactDOM.render(<App/>, document.getElementById('app'));
// cookieにトークンが入ってたらlocalStorageに移し替える
const token = document.cookie
.split('; ')
.find(row => row.startsWith('token'))
?.split('=')[1];
console.log(document.cookie);
console.log(token);
if (token) {
localStorage['token'] = token;
// 今の所はcookieをトークン以外に使用しないため全消去する
// もしcookieの用途が増えるのであればここを良い感じに書き直す必要がある
document.cookie = '';
}
ReactDOM.render(<App/>, document.getElementById('app'));