Skip to content

Conversation

@Maphikza
Copy link
Member

@Maphikza Maphikza commented Jul 7, 2025

Fix deprecated CodeQL Action versions:

  • github/codeql-action/init@v2 → @V3
  • github/codeql-action/autobuild@v2 → @V3
  • github/codeql-action/analyze@v2 → @V3

This resolves GitHub's deprecation warnings for CodeQL Action v1/v2.

NIP-07 Extension Detection & Production Build Improvements

Overview

This PR adds intelligent NIP-07 browser extension detection and improves the production build configuration for better development and
deployment workflows.

Key Features

NIP-07 Extension Detection

  • Smart Detection: Automatically detects Nostr browser extensions in the background
  • User-Friendly Guide: Shows installation guide only when no extension is detected
  • Mobile Responsive: Clean, responsive UI with direct links to browser extension stores
  • Seamless UX: Users with extensions see normal login flow immediately

Production Build Improvements

  • Environment Override: Support for localhost testing with production builds
  • Dynamic Configuration: Auto-detects API URLs while allowing environment overrides
  • Service Worker Management: Disables caching on localhost to prevent build conflicts

Documentation Updates

  • Clear Instructions: Updated README with production testing examples
  • Environment Templates: Comprehensive .env.production examples for different scenarios
  • Deployment Guide: Improved deployment instructions with proper serve commands

Technical Changes

New Components

  • NostrExtensionCheck: Responsive component with extension detection and installation guidance

Updated Components

  • LoginForm: Enhanced with background extension detection
  • config.ts: Added environment override support for production builds

Configuration

  • Service worker disabled for localhost to prevent caching issues
  • Environment variable precedence improved for production testing

Usage

Development

yarn start  # Works as before

Production Testing (New)

yarn build
npx serve -s build  # Test production build locally

Environment Configuration

Production builds now support localhost testing with environment overrides in .env.production.

 Testing

- Extension detection works for users with/without NIP-07 extensions
- Production build works with localhost services
- Service worker caching issues resolved
- Environment variable overrides functional

Fix deprecated CodeQL Action versions:
- github/codeql-action/init@v2 → @V3
- github/codeql-action/autobuild@v2 → @V3
- github/codeql-action/analyze@v2 → @V3

This resolves GitHub's deprecation warnings for CodeQL Action v1/v2.
Maphikza added 18 commits July 8, 2025 12:07
## New Features
- **NIP-07 Extension Detection**: Intelligent background detection that only shows helper UI when no extension is found
- **Production Build Environment Override**: Support localhost testing with production builds
- **Smart Extension Checking**: Auto-detects extensions on load, graceful fallback for missing extensions

## UI Improvements
- **Extension Helper Component**: Mobile-responsive guide with direct links to Chrome/Firefox stores
- **Background Detection**: Login form shows immediately for users with extensions
- **Improved UX**: Only users without extensions see the setup guide

## Technical Improvements
- **Config Updates**: Production builds now support environment variable overrides for localhost testing
- **Service Worker Management**: Disable caching on localhost to prevent build conflicts
- **Better Error Handling**: Proper timeout and cleanup for extension detection

## Documentation Updates
- **Production Testing Guide**: Instructions for localhost production build testing
- **Environment Examples**: Clear .env.production examples for different scenarios
- **Deployment Instructions**: Updated with proper serve commands

## Files Changed
- Add: NostrExtensionCheck component with mobile-responsive design
- Update: LoginForm with intelligent extension detection
- Update: config.ts with environment override support
- Update: README.md with production testing instructions
- Update: Service worker disabled for localhost testing
…ctions

- Add complete .env.development example with all required variables
- Emphasize using start-app.sh script for Node.js compatibility
- Include proper Nostr relay URLs and asset bucket configuration
- Replace hardcoded relay URLs with generic examples
- Show proper comma-separated pattern without bias
- Maintain neutrality in relay recommendations
## Major Architecture Change
- Panel now integrates directly into relay server (port 9002)
- No separate nginx proxy needed for basic deployment
- Single origin serves both React app and API endpoints

## Configuration Updates
- Simplified dynamic URL detection (same origin for panel + API)
- Removed /front and /panel path requirements
- Auto-detect WebSocket URL from current domain
- Streamlined environment configuration

## Documentation Updates
- Updated architecture diagrams for integrated deployment
- Simplified environment configuration examples
- Clarified development vs production setup
- Removed complex reverse proxy requirements

## Benefits
- ✅ Simplified deployment (single server)
- ✅ No CORS issues (same origin)
- ✅ Unified SSL certificate
- ✅ Same build works everywhere
- Remove outdated /front/ location block
- Keep wallet service proxying at /wallet/
- Maintain relay WebSocket as default location (/)
- Panel runs integrated in relay server (port 9002) - no nginx needed
- Add /panel/ location block to proxy to relay server (port 9002)
- Handle React Router SPA routing with fallback
- Update production .env.production to use /panel basename
- Now accessible at https://example.com/panel/ in production

Production URLs:
- Panel: /panel/ → port 9002 (React app + API)
- Relay: / → port 9001 (WebSocket)
- Wallet: /wallet/ → port 9003 (API)
- Remove URI path from proxy_pass in named locations (nginx requirement)
- Simplify panel routing - Go server handles React Router internally
- Update README to match working configuration
- Remove complex fallback handling that caused proxy_pass syntax error

The panel location now uses simple proxy_pass without URI conflicts.
Development (.env.development):
- Direct service connections (ports 9001, 9002, 9003)
- No base path - panel runs from root in dev mode
- Remove specific relay defaults to maintain neutrality

Production (.env.production):
- Base path /panel to match nginx routing
- Auto-detection for API URLs (same origin through nginx)
- Clean configuration for deployment
- Commented examples without favoring specific relays
- Remove hardcoded API URLs (now auto-detected)
- Set /panel base path for nginx routing
- Remove specific relay defaults to maintain neutrality
- Align with current .env.production configuration
- Clear comments about auto-detection features
Critical fixes based on backend dev feedback:
1. Add trailing slash to proxy_pass to strip /panel/ prefix properly
2. Add required proxy headers for proper request forwarding

Before: /panel/login → http://127.0.0.1:9002/panel/login (broken)
After:  /panel/login → http://127.0.0.1:9002/login (correct)

This fixes panel accessibility at https://domain.com/panel/
- Replace specific *.serveo.net with universal server_name _
- Now works with localhost, ngrok, serveo, custom domains, and any tunneling service
- Remove service-specific limitations from configuration
- Update both fixed config and README documentation
- Back to proven rewrite + break pattern that was working
- Keep the added proxy headers for proper forwarding
- Remove the trailing slash approach that broke functionality

Working pattern:
- rewrite ^/panel/(.*)$ / break strips /panel/ prefix
- proxy_pass http://127.0.0.1:9002 (no trailing slash)
- Restores https://afrihornet.ngrok.io/panel/ functionality
- Remove auto-detection fallback that was causing incorrect URL usage
- Always require REACT_APP_WALLET_BASE_URL to be explicitly set
- Prevent panel from incorrectly trying localhost:9002/wallet instead of localhost:9003
- Add clear error message when wallet URL environment variable is missing
- Include production environment configuration in repository
- Ensures wallet URL is properly configured during build process
- Required for automated deployment scripts that clone and build
- Remove auto-detection fallback for relay WebSocket URL
- Always require REACT_APP_OWN_RELAY_URL to be explicitly set
- Prevent panel from incorrectly connecting to ws://localhost:9002 instead of ws://localhost:9001
- Add clear error message when relay URL environment variable is missing
- Update .env.production with correct relay URL: ws://localhost:9001
- Document direct access deployment method that actually works
- Remove non-working reverse proxy configurations to prevent confusion
- Clarify that service URLs (wallet/relay) require explicit configuration
- Note that panel routing can be auto-detected but service URLs cannot
- Add note that reverse proxy setup still needs proper configuration example

TODO: Create working nginx configuration example for reverse proxy deployment
  - Replace complex client-side Blossom upload with simple API call
  - Use POST /api/relay/icon endpoint with JWT authentication
  - Send panel_url (auto-detected from window.location.origin) and image file
  - Backend now handles Kind 117 event creation, Blossom storage, and config updates
  - Remove dependency on direct Blossom upload utilities
  - Improve error handling and user feedback
  - Add kind 1060 (Double Ratchet DM - NIP-117) to selectable kinds
  - Add kind 1063 (File Metadata - NIP-94) to selectable kinds
  - Add kind 30078 (Application-specific Data - NIP-78) to selectable kinds
  - Update kindMapping.ts with kind 1060 description
  - All new kinds categorized under Basic Nostr Features
  - Users can now enable/disable these kinds in relay settings
@f7f376a1fcd0d0e11a10ed1b6577c9 f7f376a1fcd0d0e11a10ed1b6577c9 merged commit c845a48 into main Jul 11, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants