Skip to content

Commit

Permalink
include access token in client requests, if defined
Browse files Browse the repository at this point in the history
this allows h5web to work in CORS jupyterlab deployments
and JupyterHub 4.1 which has stricter XSRF rules
  • Loading branch information
minrk committed Apr 19, 2024
1 parent 329c874 commit a1e3392
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/H5webApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ function TwoRenderApp() {

function H5webApp(props: { filePath: string }) {
const { filePath } = props;
const { baseUrl } = ServerConnection.makeSettings();
const { baseUrl, token } = ServerConnection.makeSettings();
const headers = {};
if (token) {
headers.Authorization = `token ${token}`;

Check failure on line 31 in src/H5webApp.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'Authorization' does not exist on type '{}'.
}

const axiosConfig = useMemo(
() => ({ params: { file: filePath } }),
[filePath]
() => ({
params: { file: filePath },
headers: headers,
}),
[filePath, token]
);

return (
Expand Down

0 comments on commit a1e3392

Please sign in to comment.