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: Add bindAddress command line option to allow local-ssl-proxy to play nice with WSL #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

spapaseit
Copy link

Running local ssl proxies under WSL requires a hostname param 0.0.0.0 to be passed to the listen method for the proxy to work on the Windows browser, eg:

sslServer.listen(443, '0.0.0.0')`;

Note that adding this hostname has no effect on users not unnning under WSL.

This PR adds a --bindAddress command line option that is respected both when passing a proxy through args, and when using a config file.
bindAddress cannot be passed through the config file itself, as it is not a proxy-specific argument and would have required changing the structure of the config file, which didn't seem wise.

Copy link

changeset-bot bot commented Nov 8, 2024

⚠️ No Changeset found

Latest commit: 30087b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -30,10 +30,10 @@
},
"devDependencies": {
"@tsconfig/node-lts-strictest": "^18.12.1",
"@types/http-proxy": "^1.17.10",
"@types/http-proxy": "1.17.15",
Copy link
Author

Choose a reason for hiding this comment

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

v1.17.10 didn't include the hostname parameter on the .listen method, hence the update.

import { isProxy, isConfig, parse, ParsedArguments, Proxy, Config } from '../src/lib';


function expectProxy(result: ParsedArguments): Proxy {
Copy link
Author

Choose a reason for hiding this comment

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

Type guard functions to keep TypeScript happy on the tests.
After changing ParsedArguments to export type ParsedArguments = (Proxy | Config) & BindAddress; to include bindAddress, TypeScript was unable to infer the correct type from the return of the call to parse

@spapaseit spapaseit marked this pull request as ready for review November 8, 2024 12:37
@spapaseit spapaseit changed the title feat: feat: Add bindAddress command line option to allow local-ssl-proxy to play nice with WSL feat: Add bindAddress command line option to allow local-ssl-proxy to play nice with WSL Nov 8, 2024

function isConfig(args: unknown): args is Config {
export function isConfig(args: unknown): args is Config {
Copy link
Author

Choose a reason for hiding this comment

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

Exported so it can be used in unit-tests

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.

1 participant