Skip to content

patchUrlMappings does not support targets with parameter matched ports #302

@joeynenni

Description

@joeynenni

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions