API documentation with AWS Cognito integration, supporting development, staging, and production environments.
npm install# Copy example environment file
cp env.example .env.local
# Edit with your actual credentials
nano .env.local# Option 1: Use the convenience script (recommended)
./start-dev.sh
# Option 2: Use npm directly
npm run dev
# Server will start on http://localhost:4321- Open
http://localhost:4321 - Click "Cognito Test" in the sidebar
- Test your AWS Cognito integration
npm run dev
# Uses: .env.local or config.js defaultsnpm run dev:staging
# Uses: .env.staging.local or staging confignpm run dev:prod
# Uses: environment variables from hosting platform- AWS Cognito OAuth2: Client credentials flow for server-to-server authentication
- API Documentation: Complete OpenAPI specification with examples
- Multi-Environment: Development, staging, and production configurations
- Security Best Practices: Secure credential management and deployment
- OpenAPI 3.0: Complete API specification with examples
- Responsive Design: Works on desktop and mobile devices
- Setup Guide: Complete setup instructions
- Cognito Test: Testing guide and examples
- API Reference: Complete API documentation
- Security Guide: Security best practices
auth_integration/
βββ src/
β βββ content/docs/ # Documentation pages
β β βββ setup-guide.mdx # Setup instructions
β β βββ cognito-test.mdx # Testing page
β β βββ index.mdx # Home page
β βββ assets/ # Images and assets
βββ config.js # Environment configuration
βββ openapi.yaml # API specification
βββ astro.config.mjs # Astro/Starlight configuration
βββ test-cognito.html # Standalone test page
βββ start-dev.sh # Development server convenience script
βββ env.example # Example environment variables
βββ .gitignore # Git ignore rules
βββ SECURITY-GUIDE.md # Security documentation
# .env.local (KEEP LOCAL - Never commit)
NODE_ENV=development
COGNITO_DOMAIN=your-dev-cognito-domain.auth.region.amazoncognito.com
COGNITO_CLIENT_ID=your_dev_client_id
COGNITO_CLIENT_SECRET=your_dev_client_secret
COGNITO_SCOPE=cognito-api-scope
API_BASE_URL=http://localhost:3000/v1# .env.staging.local (KEEP LOCAL - Never commit)
NODE_ENV=staging
COGNITO_DOMAIN=your-staging-cognito-domain.auth.region.amazoncognito.com
COGNITO_CLIENT_ID=your_staging_client_id
COGNITO_CLIENT_SECRET=your_staging_client_secret
COGNITO_SCOPE=cognito-api-scope
API_BASE_URL=https://staging-api.example.com/v1Set environment variables in your hosting platform:
# Production Environment Variables (Set in hosting platform)
NODE_ENV=production
COGNITO_DOMAIN=your-prod-cognito-domain.auth.region.amazoncognito.com
COGNITO_CLIENT_ID=your_prod_client_id
COGNITO_CLIENT_SECRET=your_prod_client_secret
COGNITO_SCOPE=cognito-api-scope
API_BASE_URL=https://api.example.com/v1| Command | Action |
|---|---|
npm install |
Installs dependencies |
npm run dev |
Starts development server |
npm run dev:staging |
Starts staging server |
npm run dev:prod |
Starts production server |
npm run build |
Build for development |
npm run build:staging |
Build for staging |
npm run build:prod |
Build for production |
npm run preview |
Preview your build locally |
- Local Development:
.env.local- Development configuration (excluded from version control) - Staging Environment:
.env.staging.local- Staging configuration (excluded from version control) - Production Environment: Environment variables configured in hosting platform
- Excluded Files: Environment files with credentials are automatically excluded from version control
- Template Files: Configuration templates with placeholder values are included
- Source Code: All application code and documentation are version controlled
- Push to GitHub: Push your code to a GitHub repository
- Enable Pages: Go to repository Settings β Pages
- Select Source: Choose "GitHub Actions" as the source
- Automatic Deployment: Every push to
mainbranch will deploy automatically
Your site will be available at: https://casparhealth.github.io/auth-integration
Note: Configuration is already set up for casparhealth organization.
# Build the project
npm run build:prod
# Upload dist/ folder to your hosting provider- Go to
http://localhost:4321/api - View the complete API specification
- Use the provided code examples to test the OAuth2 token endpoint
- Invalid Client Credentials: Check your
client_idandclient_secret - CORS Error: Add your domain to Cognito allowed origins
- Environment Variables Not Loading: Check if
.env.localfile exists - Build Errors: Verify Node.js version (18+ required)
- Check environment variables:
echo $NODE_ENV - Test Cognito endpoint directly with cURL
- Check server logs:
npm run dev -- --verbose
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Ready to get started? Follow the Setup Guide for detailed instructions!