Skip to content

Commit

Permalink
fix 302 redirect URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
benStre committed Feb 9, 2024
1 parent 05b9196 commit 6602584
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app/default-domain.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Datex } from "datex-core-legacy/mod.ts";

export function getDefaultDomainPrefix() {
return Datex.Unyt.endpointDomains()[0] ?? '';
}
8 changes: 5 additions & 3 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,10 @@ export class Server {
if (valid) {
const session = createSession(endpoint);
const headers = new Headers();
const url = new URL(requestEvent.request.url);
deleteCookie('datex-endpoint-validation', headers, port)
setCookieUIX('uix-session', session, undefined, headers, port)
headers.set("Location", requestEvent.request.url);
headers.set("Location", url.pathname+url.search);
await this.serveContent(requestEvent, "text/plain", "", undefined, 302, headers, false);
return false;
}
Expand All @@ -415,7 +416,7 @@ export class Server {
let endpoint: Datex.Endpoint|undefined;

// session/endpoint handling:
if ((this as any)._uix_init && Server.isBrowserClient(requestEvent.request) && (requestEvent.request.headers.get("Sec-Fetch-Dest") == "document" || requestEvent.request.headers.get("Uix-Inline-Backend") == "true" /*|| requestEvent.request.headers.get("Sec-Fetch-Dest") == "iframe"*/) && requestEvent.request.headers.get("connection")!="Upgrade") {
if ((this as any)._uix_init && Server.isBrowserClient(requestEvent.request) && (requestEvent.request.headers.get("Sec-Fetch-Dest") == "document" || requestEvent.request.headers.get("UIX-Inline-Backend") == "true" /*|| requestEvent.request.headers.get("Sec-Fetch-Dest") == "iframe"*/) && requestEvent.request.headers.get("connection")!="Upgrade") {

const port = new URL(requestEvent.request.url).port;
const datexEndpointCookie = getCookie("datex-endpoint", requestEvent.request.headers, port);
Expand Down Expand Up @@ -454,9 +455,10 @@ export class Server {
// no valid new session, remove session cookie
else {
const headers = new Headers();
const url = new URL(requestEvent.request.url);
deleteCookie('datex-endpoint-validation', headers, port)
deleteCookie('uix-session', headers, port)
headers.set("Location", requestEvent.request.url);
headers.set("Location", url.pathname+url.search);
await this.serveContent(requestEvent, "text/plain", "", undefined, 302, headers, false);
return;
}
Expand Down

0 comments on commit 6602584

Please sign in to comment.