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

patchUrlMappings does not support targets with parameter matched ports #302

Open
joeynenni opened this issue Feb 1, 2025 · 1 comment
Open

Comments

@joeynenni
Copy link

Now that the discord proxy supports targets with a custom port in the URL Mappings (confirmed it works), I have decided to file this issue again.

The current implementation of patchUrlMappings produces the following result when a client app served from 1234.discordsays.com tries making a request to 86d96a.edge.hathora.dev:51738 with a parameter matched port in the target:

patchUrlMappings([{ prefix: '/hathora/edge/{subdomain}/{port}', target: '{subdomain}.edge.hathora.dev:{port}' }])

Expected result: Client app makes a request to 1234.discordsays.com/hathora/edge/86d96a/51738 instead of 86d96a.edge.hathora.dev:51738

Actual result: An error occurs on client app on load (Uncaught TypeError: Failed to construct 'URL': Invalid URL at matchAndRewriteURL)

This error occurs because the line at https://github.com/discord/embedded-app-sdk/blob/main/src/utils/url.ts#L36 attempts to construct a new URL with the target value. However, if the target value has a non-numeric port (like the parameter matched :{port} from the example) then the URL constructor will fail.

@joeynenni
Copy link
Author

I submitted a PR to fix this issue: #303

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

No branches or pull requests

1 participant