Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change default rpc config + upgrade CORS library (#1118)
## Description This PR introduces several changes to the default JSON-RPC config of the Gno node: - allow all (`*`) origin requests by default. The reasoning behind this is that local development setups that require the RPC layer will have their requests rejected by the CORS policy, and will require a custom RPC config to be specified to the node. This is more of a convenience on the side of development, as production Gno RPC setups will have a concrete RPC configuration that is more limited - explicitly allow `OPTIONS` requests (preflight requests) in the default configuration - change the CORS library used in the project from [gnolang/cors](https://github.com/gnolang/cors) to [rs/cors](https://github.com/rs/cors). The [gnolang/cors](https://github.com/gnolang/cors) library is a fork of [rs/cors](https://github.com/rs/cors), with seemingly no functionality changes. Therefore, to stay up to date with the latest fixes and upstream changes, I've updated the library gno uses to the original one, which is actively maintained by the original authors ### How can I test this out? Essentially, you can run the local node with the default RPC params, and try to do an HTTP request from a frontend application: ```ts import { GnoJSONRPCProvider } from "@gnolang/gno-js-client"; const exampleMethod = async () => { // Local node as the endpoint const provider = new GnoJSONRPCProvider("http://127.0.0.1:26657"); const blockNumber: number = await provider.getBlockNumber(); console.log(blockNumber); }; exampleMethod() .then(() => { console.log("success"); }) .catch((e) => { console.error(e); }); ``` Example error: <img width="1192" alt="Screenshot 2023-09-13 at 12 27 22" src="https://github.com/gnolang/gno/assets/16712663/603b58c7-577d-4970-80eb-1c5984e0744b"> <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details>
- Loading branch information