Код: Выделить всё
async loadBundle(){
if (this.loaded){
return;
}
const [style, bundle] = await Promise.all([
fetch("/styleAdmin", {
method: "GET",
headers: {
"Authorization": "Bearer "+this.token,
"Cache-Control": "no-store"
}
}),
fetch("/bundleAdmin", {
method: "GET",
headers: {
"Authorization": "Bearer "+this.token,
"Cache-Control": "no-store"
}
})
]);
if (style.status !== 200 || bundle.status !== 200){
throw new Error('Loading error.');
}
const [css, js] = await Promise.all([style.text(), bundle.text()]);
this.loaded = true;
const styleTag = document.createElement("style");
styleTag.innerHTML = css;
const scriptTag = document.createElement("script");
scriptTag.innerHTML = js;
document.head.appendChild(styleTag);
document.head.appendChild(scriptTag);
}
Я не горжусь этим кодом. Я имею в виду, что это почему-то кажется неправильным, но поскольку у меня нет сеанса на стороне сервера и файла cookie сеанса, я не уверен, как решить эту проблему с помощью JWT.
Еще одна вещь на стороне сервера: я хочу обслуживать статические файлы с помощью CloudFlare из AWS S3, и я не уверен, как там проверить JWT.
Подробнее здесь: https://stackoverflow.com/questions/799 ... t-with-jwt
Мобильная версия