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 41d2046
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/H5webApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ function TwoRenderApp() {

function H5webApp(props: { filePath: string }) {
const { filePath } = props;
const { baseUrl } = ServerConnection.makeSettings();
const { baseUrl, token } = ServerConnection.makeSettings();

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

return (
Expand Down

0 comments on commit 41d2046

Please sign in to comment.