mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 11:34:07 +01:00
31 lines
704 B
JavaScript
31 lines
704 B
JavaScript
import React from 'react';
|
|
import ReactDOM from 'react-dom/client';
|
|
import './index.css';
|
|
import * as gateway from "./api/gateway";
|
|
import App from "./App";
|
|
|
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
root.render(
|
|
<App />
|
|
);
|
|
|
|
gateway.init({
|
|
url: '/api/v1',
|
|
getAuthorization
|
|
});
|
|
|
|
function getAuthorization(security) {
|
|
switch(security.id) {
|
|
case 'key': return getApiKey();
|
|
default: console.log('default');
|
|
}
|
|
}
|
|
|
|
function getApiKey() {
|
|
const localUser = JSON.parse(localStorage.getItem("user"))
|
|
if(localUser) {
|
|
return Promise.resolve({ apiKey: localUser.token });
|
|
} else {
|
|
throw new Error("token not available");
|
|
}
|
|
} |