A full-stack, secure file sharing application designed to let users safely upload, manage, and distribute files via encrypted Cloudflare R2 object storage. Features a modern React frontend and a robust Node.js/Express backend, with PostgreSQL (Neon) for metadata and relationship management.
- Secure Object Storage: All generic files are stored seamlessly into Cloudflare R2 via securely generated short-lived AWS S3 Pre-signed URLs.
- Granular Link Sharing: Generate tokenized share links with custom expiry times (
expires_at) and specific scoped permissions (viewordownload). - In-App File Viewer: Directly preview images, videos, and PDFs right from the browser window securely using the customized Vite frontend app.
- Auto-Redirect Direct Downloads: Automatically triggers secure file downloads for users visiting links configured strictly for downloading.
- JWT Authentication: Strict JSON Web Token based stateless sessions.
- API Security: Fully configured with
helmet,cors, andexpress-rate-limitto handle rapid deployments to services like Render and Vercel.
Frontend:
- React 18
- Vite
- React Router DOM
- CSS Modules & Inline Styling Framework
Backend:
- Node.js & Express.js
- PostgreSQL (Powered by Neon) +
pgdriver @aws-sdk/client-s3(For Cloudflare R2 integration)- JSON Web Tokens (JWT) & bcrypt
- Node.js (v18+)
- A PostgreSQL Database (e.g., Neon.tech)
- A Cloudflare R2 bucket with API keys.
git clone https://github.com/kash-gg/Secure-File-Sharing-Platform.git
cd Secure-File-Sharing-Platformcd backend
npm installCreate a .env file in the backend folder:
PORT=5000
DATABASE_URL=postgresql://<user>:<password>@<host>/<dbname>?sslmode=require
JWT_SECRET=your_super_secret_jwt_key
# Cloudflare R2 Configuration
R2_ACCESS_KEY_ID=your_cloudflare_access_key
R2_SECRET_ACCESS_KEY=your_cloudflare_secret_key
R2_BUCKET_NAME=your_bucket_name
R2_ENDPOINT=https://<account_id>.r2.cloudflarestorage.com
# For production cross-domain cookie configurations (Vercel -> Render)
NODE_ENV=development
FRONTEND_URL=http://localhost:5173Run database migrations:
npm run migrateStart the backend standard development server:
npm run devIn a new terminal window:
cd frontend
npm installCreate a .env file in the frontend folder:
VITE_API_BASE_URL=http://localhost:5000Start the Vite development server:
npm run devOpen http://localhost:5173 in your browser.
This app is optimized for a split-deployment model: Frontend on Vercel, and Backend on Render.
- Create a Web Service on Render pointing to your
backend/directory. - Set
Build Commandtonpm installandStart Commandtonpm start. - Fill out all
.envvariables from above directly into the Render Environment dashboard. - Critically: Ensure you set
NODE_ENV=productioninside Render so that cross-site cookies are configured withSameSite: "none".
- Import your project into Vercel and set the "Root Directory" to
frontend. - Vercel should auto-detect Vite as your preset framework.
- Under Environment Variables, set
VITE_API_BASE_URLto your live Render backend URL (e.g.,https://my-backend.onrender.com). - The project incorporates a
vercel.jsonfile insidefrontend/to fix Single Page Application (SPA) routing 404 errors by default.
Built with ❤️ for Secure Data Management.