为什么 publicProvider 不工作 wagmi,next.js

问题描述 投票:0回答:1

我在我的应用程序中使用 wagmi 但我对 publicProvider 有问题我正在使用多边形网络但是当我切换到主网时我有相同的 我的 wagmiConfig:

import { createClient, configureChains, mainnet } from 'wagmi'
import { publicProvider } from 'wagmi/providers/public'
import { polygonMumbai } from 'wagmi/chains'
import '@rainbow-me/rainbowkit/styles.css';
import {
  getDefaultWallets,
} from '@rainbow-me/rainbowkit';

export const {chains, provider, webSocketProvider } = configureChains(
  [polygonMumbai],
  [publicProvider()],
  )

  const { connectors } = getDefaultWallets({
    appName: 'My RainbowKit App',
    chains
  });

  export const client = createClient({
    autoConnect: true,
    provider,
    webSocketProvider,
    connectors
  });

Access to fetch at 'https://matic-mumbai.chainstacklabs.com/' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:3000' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
POST https://matic-mumbai.chainstacklabs.com/ net::ERR_FAILED

我尝试更换其他供应商,但每次都是相同的结果

next.js provider metamask
1个回答
0
投票

我也收到这个错误:

next-dev.js?3515:20 Error: missing response (requestBody="{\"method\":\"eth_getBalance\",\"params\":[\"0x42bab0e8f3aef8e4fdef4fb8331e903381dd2e34\",\"latest\"],\"id\":42,\"jsonrpc\":\"2.0\"}", requestMethod="POST", serverError={}, url="https://matic-mumbai.chainstacklabs.com", code=SERVER_ERROR, version=web/5.7.1)
© www.soinside.com 2019 - 2024. All rights reserved.