Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement ngrok v1 proxy for serve command #4

Merged
merged 2 commits into from
Feb 12, 2025
Merged

Conversation

odanado
Copy link
Member

@odanado odanado commented Feb 5, 2025

Description

I implemented the integration with ngrok v1 as one of the integrations for the Tunnel feature.
This feature uses ngrok to tunnel the URL passed to the serve command, and sets the ngrok URL as the endpoint URL for the LIFF app.

Below is what the terminal looks like when the command is executed:

❯ npx @line/liff-cli serve -l 1234567890-aBcDeFg -u http://127.0.0.1:8081 --proxy-type ngrok-v1 --ngrok-command ngrok
Successfully updated endpoint url for LIFF ID: 1234567890-aBcDeFg.

→  LIFF URL:     https://liff.line.me/1234567890-aBcDeFg
→  Proxy server: https://abc123.ngrok.example.com/

In order for users to use this feature, they need to install node-pty.
node-pty is a large package.
ref: https://bundlephobia.com/package/[email protected]

Because not all users will use the ngrok v1 integration feature, I specified it in peerDependencies.

@odanado odanado changed the title implement ngrok v1 proxy for serve command Implement ngrok v1 proxy for serve command Feb 5, 2025
@CLAassistant
Copy link

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

@odanado odanado force-pushed the support-ngrok-v1 branch 3 times, most recently from 99ecac6 to b5eb6f2 Compare February 6, 2025 09:27
@odanado odanado changed the title Implement ngrok v1 proxy for serve command feat: Implement ngrok v1 proxy for serve command Feb 6, 2025

const shell = os.platform() === "win32" ? "powershell.exe" : "bash";
const pty = await tryImportNodePty();
this.ptyProcess = pty.spawn(shell, [], {
Copy link
Member Author

Choose a reason for hiding this comment

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

ngrok v1 does not allow us to obtain connection information in a format that is easy for programs to handle, like JSON.
ref: inconshreveable/ngrok#86

Therefore, we need to use node-pty.

@odanado odanado marked this pull request as ready for review February 6, 2025 10:27
@odanado odanado requested a review from a team as a code owner February 6, 2025 10:27
@odanado odanado merged commit 01ca03d into main Feb 12, 2025
3 checks passed
@odanado odanado deleted the support-ngrok-v1 branch February 12, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants