• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
cookiemonster0921

cookiemonster0921

discordActivity

Public
Like
discordActivity
Home
Code
11
embedded-app-sdk-main
22
.vtignore
AGENTS.md
H
client.ts
deno.json
discordmin.js
H
ex1.ts
index.html
H
main.ts
H
ret.ts
script.js
Branches
1
Pull requests
Remixes
History
Environment variables
2
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
embedded-app-sdk-main
/
patch-url-mappings.md
Code
/
embedded-app-sdk-main
/
patch-url-mappings.md
Search
11/21/2025
Viewing readonly version of main branch: v183
View latest version
patch-url-mappings.md

patchUrlMappings

Activities in the Discord ecosystem are “sandboxed” via a discord proxy. This is done to hide the users’ IP addresses as well as block urls from known malicious endpoints. To achieve this, the developer portal has a section for embedded applications called "URL Mappings". One edge-case of URL mappings is that third-party npm modules may reference external (non-sandbox'd) urls.

For example, if your application has an npm module that attempts to make an http request to https://foo.library.com, the request will fail with a blocked:csp error.

To get around this limitation there are several options to consider:

  • Fork the library (to use mapped urls)
  • Utilize a post-install utility such as patch-package
  • Use embedded-app-sdk's patchUrlMappings api

In the above scenario we recommend the patchUrlMappings api, as it will allow a smooth transition from the non-sandboxed dev environment to the prod environment. This api call takes an array of "mappings" which will transform any external network requests to the mappings you've defined.

See the example below: In this example, imagine you have a third party library which makes an http request to foo.com In the developer portal, create a mapping like this: /foo -> foo.com Then in your code, when initializing the embedded-app-sdk, you will make a function call like this:

Create val
import {patchUrlMappings} from '@discord/embedded-app-sdk'; patchUrlMappings([{prefix: '/foo', target: 'foo.com'}]);

Note: patchUrlMappings is modifying your browser's fetch, WebSocket, and XMLHttpRequest.prototype.open global variables, as well as modifying any html element's src attribute. Depending on the library, you may see side effects from using this helper function. It should be used only when necessary.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.