Content Security Policy
Content Security Policy
#Overview
The Content Security Policy (CSP) of a browser dictates what resources can load. Magic maintains a predefined list of RPC URLs in the CSP. You can find these RPC URLs in the page relevant to your chosen blockchain. If you are using a Dedicated Wallet, you can update the policy on the Settings page of the dashboard with a custom URL.
#Use cases
- Use the connect-src directive to allow specific URLs, such as a custom RPC URL to send transactions to your node
#Usage
When connecting to a custom RPC node, ensure that the URL you use in your code has been added to the CSP in your Magic Dashboard.
01
02const customNodeOptions = {
03 rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/xyz', // Your own node URL
04 chainId: 1011, // Your own node's chainId
05};
06
07// Setting network to localhost blockchain
08const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', {
09 network: customNodeOptions,
10});