A minimal Vite + React project designed to test and reproduce port forwarding issues in Gitpod/Ona environments. This project is inspired by production Vite configurations and includes diagnostic tools to verify port forwarding behavior.
This test environment simulates a typical Vite development server setup with:
- Port 3002 configuration
- Proxy configuration for API routes
- Host binding to
0.0.0.0for external access - Interactive UI for testing port forwarding and proxy functionality
.
├── src/
│ ├── App.tsx # Main React component with diagnostics UI
│ ├── main.tsx # React entry point
│ └── index.css # Basic styles
├── index.html # HTML entry point
├── vite.config.ts # Vite configuration with port and proxy settings
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── tsconfig.node.json # TypeScript config for Vite config file
The vite.config.ts includes key settings for port forwarding:
server: {
port: 3002,
host: '0.0.0.0', // Required for external access
allowedHosts: true, // Allows all hosts (including Gitpod URLs)
strictPort: true,
proxy: {
'/api': {
target: 'https://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
}Important Notes:
host: '0.0.0.0'is required for Gitpod/Ona port forwarding to workhost: '127.0.0.1'will result in "Service Unavailable" errorsallowedHosts: trueallows access from Gitpod's dynamic URLs- See Ona Ports Documentation for more info
- Node.js (v18 or higher recommended)
- npm or yarn
npm installnpm run devThe server will start on port 3002. In Gitpod/Ona environments, the port will be automatically forwarded.
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production build
Once the server is running, the UI provides several diagnostic features:
Displays:
- Configured port (3002)
- Current host
- Protocol (http/https)
- Full URL
- Click "Test Proxy" button to verify proxy configuration
- Makes a request to
/api/posts/1which is proxied tojsonplaceholder.typicode.com - Shows success/error status and response data
Lists key configuration details to verify during testing
If you receive a 403 error when accessing the forwarded URL:
-
Check host binding:
// ❌ Wrong - will cause 403 host: '127.0.0.1' // ✅ Correct host: '0.0.0.0'
-
Verify allowedHosts:
// Option 1: Allow all hosts allowedHosts: true // Option 2: Specify allowed hosts allowedHosts: ['.flex.doptig.cloud', 'localhost']
-
Check port status:
gitpod environment port list
-
Verify server is running:
curl http://localhost:3002
-
Check if port is forwarded:
gitpod environment port list
-
Restart the server:
- Stop the current server (Ctrl+C)
- Run
npm run devagain
- Check browser console for CORS or network errors
- Verify proxy configuration in
vite.config.ts - Test direct access to the proxy target URL
This test environment can help reproduce:
- ✅ Port forwarding with
host: '0.0.0.0'vshost: '127.0.0.1' - ✅
allowedHostsconfiguration issues - ✅ Proxy configuration in forwarded environments
- ✅ HTTPS/HTTP protocol handling
- ✅ Dynamic URL patterns in Gitpod/Ona
react^18.2.0react-dom^18.2.0
vite^5.0.0@vitejs/plugin-react^4.2.0typescript^5.3.0@types/react^18.2.0@types/react-dom^18.2.0
This project is based on a production Vite configuration that includes:
- React with SWC plugin
- Lingui for internationalization
- Sentry integration
- Bundle analyzer
- Complex proxy setup for multiple API routes
The test environment simplifies this to focus on port forwarding behavior while maintaining the essential configuration patterns.
Useful commands for managing ports in Gitpod/Ona:
# List all forwarded ports
gitpod environment port list
# Open a port (if not already open)
gitpod environment port open <port>
# Close a port
gitpod environment port close <port>This is a test project for reproducing customer issues. Use freely for debugging and testing purposes.