Skip to content

Commit

Permalink
Update runners.py
Browse files Browse the repository at this point in the history
interaction path agnostic (use the real path where the page is served ("coder" compliant))
  • Loading branch information
manatlan authored Nov 7, 2024
1 parent 3b76865 commit 2f49691
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions htagweb/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ async def handle(self, request,
jslib += "\nasync function _write_(x) {return x}\n"
pparano=""


jslib += "let webroot = document.location.pathname || '/';"

if is_http_only:
# interactions use HTTP POST
js = """%(jslib)s
async function interact( o ) {
let body = await _write_(JSON.stringify(o));
let req=await window.fetch("/_/%(fqn)s%(pparano)s",{method:"POST", body: body, mode: 'cors', credentials: 'include', referrerPolicy: "origin"});
let req=await window.fetch(webroot + "_/%(fqn)s%(pparano)s",{method:"POST", body: body, mode: 'cors', credentials: 'include', referrerPolicy: "origin"});
let actions=await req.text();
action( await _read_(actions) );
}
Expand All @@ -301,7 +301,7 @@ async def handle(self, request,
let retryms=500;
function connect() {
_WS_= new WebSocket("//"+location.host+"/_/%(fqn)s%(pparano)s");
_WS_= new WebSocket("//" + location.host + webroot + "_/%(fqn)s%(pparano)s");
_WS_.onopen=function(evt) {
console.log("** WS connected")
document.body.classList.remove("htagoff");
Expand Down

0 comments on commit 2f49691

Please sign in to comment.