Skip to content

Commit

Permalink
Merge pull request #87 from JJ-8/csp-fix-hotkey-in-iframe
Browse files Browse the repository at this point in the history
Serve hotkeys-iframe.js from a path from Hedgedoc to circumvent CSP
  • Loading branch information
JJ-8 authored Mar 16, 2024
2 parents 91b6d31 + 3917e0f commit 5de2ad2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions front/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ server {
add_header Pragma "no-cache";
}

# Due to the CSP of Hedgedoc, we need to serve the hotkeys-iframe.js file from here to allow execution
location /pad/js/hotkeys-iframe.js {
root /usr/share/nginx/html;
try_files $uri /hotkeys-iframe.js =404;
}

location /pad/ {
proxy_pass http://hedgedoc:3000/;
proxy_http_version 1.1;
Expand Down
2 changes: 1 addition & 1 deletion front/src/pages/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default defineComponent({
// inject hotkey script with some CTFNote code to catch hotkey for search dialog
// and communicate that with the parent window
const hotkeyScript = taskFrame.document.createElement('script');
hotkeyScript.src = '/hotkeys-iframe.js';
hotkeyScript.src = '/pad/js/hotkeys-iframe.js'; // this won't exist in development but will in production
taskFrame.document.body.appendChild(hotkeyScript);
});
});
Expand Down

0 comments on commit 5de2ad2

Please sign in to comment.