Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/serve/proxy/ngrok-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class NgrokProxy implements ProxyInterface {
constructor() {}

async connect(targetUrl: URL): Promise<URL> {
const targetPort = targetUrl.port;
const targetPort =
targetUrl.port || (targetUrl.protocol === "https:" ? "443" : "80");
const targetHost = targetUrl.hostname;

if (!process.env.NGROK_AUTHTOKEN) {
Expand Down Expand Up @@ -36,7 +37,11 @@ export class NgrokProxy implements ProxyInterface {

listener.forward(`${targetHost}:${targetPort}`);

return new URL(url);
const urlWithPath = new URL(url);
urlWithPath.pathname = targetUrl.pathname;
urlWithPath.search = targetUrl.search;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's uncommon for LIFF app endpoint URLs to include a hash, but could you also include the hash in urlWithPath, just like pathname and search, to ensure that NgrokProxy correctly forwards the entire URL?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added urlWithPath.hash.

urlWithPath.hash = targetUrl.hash;
return urlWithPath;
}

async cleanup(): Promise<void> {
Expand Down