mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 04:27:56 +00:00
fix: Configure WebSocket endpoint from environment variables
## Problem Frontend was showing 'connecting network' message on production (pezkuwichain.io) because: 1. WebSocket endpoint was hardcoded to localhost in App.tsx 2. DEFAULT_ENDPOINT in polkadot.ts was not reading environment variables ## Solution ### shared/blockchain/polkadot.ts - Added getWebSocketEndpoint() function to read VITE_NETWORK and corresponding VITE_WS_ENDPOINT_* env vars - Changed DEFAULT_ENDPOINT from hardcoded value to call getWebSocketEndpoint() - Now correctly uses wss://ws.pezkuwichain.io in production ### web/src/App.tsx - Removed hardcoded endpoint="ws://127.0.0.1:9944" prop from PolkadotProvider - Now uses DEFAULT_ENDPOINT which reads from environment ### web/vite.config.ts - Minor formatting improvements (no functional changes) ### CLAUDE_README_KRITIK.md (New file) - Critical documentation for future Claude instances - Documents VPS validator setup, bootnode configuration - Strict warnings not to modify working blockchain - Troubleshooting commands and procedures - Frontend deployment steps ## Result - Production site now correctly connects to wss://ws.pezkuwichain.io - Environment-based configuration working as expected - Local dev still uses ws://127.0.0.1:9944 ## Files Changed - shared/blockchain/polkadot.ts: Dynamic endpoint selection - web/src/App.tsx: Remove hardcoded endpoint - CLAUDE_README_KRITIK.md: Critical documentation (new)
This commit is contained in:
@@ -17,15 +17,32 @@ export const PEZKUWI_NETWORK: BlockchainNetwork = {
|
||||
* Common blockchain endpoints
|
||||
*/
|
||||
export const BLOCKCHAIN_ENDPOINTS = {
|
||||
mainnet: 'wss://pezkuwichain.app:9944',
|
||||
beta: 'wss://beta-rpc.pezkuwi.art',
|
||||
mainnet: 'wss://mainnet.pezkuwichain.io',
|
||||
testnet: 'wss://ws.pezkuwichain.io',
|
||||
local: 'ws://127.0.0.1:9944',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Default endpoint (currently using beta testnet)
|
||||
* Get the appropriate WebSocket endpoint based on environment
|
||||
*/
|
||||
export const DEFAULT_ENDPOINT = BLOCKCHAIN_ENDPOINTS.beta;
|
||||
function getWebSocketEndpoint(): string {
|
||||
const network = import.meta.env.VITE_NETWORK || 'local';
|
||||
|
||||
switch (network) {
|
||||
case 'mainnet':
|
||||
return import.meta.env.VITE_WS_ENDPOINT_MAINNET || BLOCKCHAIN_ENDPOINTS.mainnet;
|
||||
case 'testnet':
|
||||
return import.meta.env.VITE_WS_ENDPOINT_TESTNET || BLOCKCHAIN_ENDPOINTS.testnet;
|
||||
case 'local':
|
||||
default:
|
||||
return import.meta.env.VITE_WS_ENDPOINT_LOCAL || BLOCKCHAIN_ENDPOINTS.local;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default endpoint (reads from environment variables)
|
||||
*/
|
||||
export const DEFAULT_ENDPOINT = getWebSocketEndpoint();
|
||||
|
||||
/**
|
||||
* Get block explorer URL for a transaction
|
||||
|
||||
Reference in New Issue
Block a user