Skip to content

Commit 7384aca

Browse files
committed
Remove landing page redirect – it breaks login handling
1 parent daa2925 commit 7384aca

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

packages/php-wasm/node/src/lib/networking/outbound-ws-to-tcp-proxy.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ async function onWsConnect(client: any, request: http.IncomingMessage) {
206206
clientLog("can't resolve " + reqTargetHost + ' due to:', e);
207207
// Send empty binary data to notify requester that connection was
208208
// initiated
209-
client.send([]);
210-
client.close(3000);
209+
setTimeout(() => {
210+
client.send([]);
211+
client.close(3000);
212+
});
211213
return;
212214
}
213215
} else {
@@ -238,7 +240,12 @@ async function onWsConnect(client: any, request: http.IncomingMessage) {
238240
});
239241
target.on('error', function (e: any) {
240242
clientLog('target connection error', e);
241-
target.end();
242-
client.close(3000);
243+
setTimeout(() => {
244+
client.send([]);
245+
client.close(3000);
246+
if (target) {
247+
target.end();
248+
}
249+
});
243250
});
244251
}

packages/playground/cli/src/run-cli.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
488488
const fileLockManager = new FileLockManagerForNode(nativeFlockSync);
489489

490490
let wordPressReady = false;
491-
let isFirstRequest = false; // Set to true after booting WordPress
491+
let isFirstRequest = true;
492+
let isSecondRequest = false;
492493

493494
logger.log('Starting a PHP server...');
494495

@@ -625,7 +626,6 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
625626

626627
await playground.isReady();
627628
wordPressReady = true;
628-
isFirstRequest = true;
629629
logger.log(`Booted!`);
630630

631631
if (compiledBlueprint) {
@@ -753,10 +753,11 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
753753
// assume they don't have to auto-login again.
754754
if (isFirstRequest) {
755755
isFirstRequest = false;
756+
isSecondRequest = true;
756757
const headers: Record<string, string[]> = {
757758
'Content-Type': ['text/plain'],
758759
'Content-Length': ['0'],
759-
Location: [compiledBlueprint.landingPage],
760+
Location: ['/'],
760761
};
761762
if (
762763
request.headers?.['cookie']?.includes(
@@ -767,14 +768,7 @@ export async function runCLI(args: RunCLIArgs): Promise<RunCLIServer> {
767768
'playground_auto_login_already_happened=1; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/',
768769
];
769770
}
770-
return new PHPResponse(
771-
302,
772-
{
773-
'Content-Length': ['0'],
774-
Location: [compiledBlueprint.landingPage],
775-
},
776-
new Uint8Array()
777-
);
771+
return new PHPResponse(302, headers, new Uint8Array());
778772
}
779773
return await loadBalancer.handleRequest(request);
780774
},

0 commit comments

Comments
 (0)