SPA Deploy Service

Deploy your static web applications instantly to get a shareable URL

Overview

Deploy your static web applications instantly.

Deploy with cURL

The simplest way to deploy is using cURL with a ZIP file of your built app:

curl -X POST https://aiswforge.com/api/spa-deploy/deploy \
  -F "file=@dist.zip" \
  -F "projectId=my-project" \
  -F "userId=user123"

Creating a ZIP file

# For React (after npm run build)
cd build && zip -r ../dist.zip . && cd ..

# For Vue/Vite (after npm run build)
cd dist && zip -r ../dist.zip . && cd ..

# For Next.js (after npm run build)
cd out && zip -r ../dist.zip . && cd ..

Response

{
  "success": true,
  "deployment": {
    "id": "happy-panda-x7k9",
    "url": "https://happy-panda-x7k9.user-spa.com",
    "files": 15,
    "totalSize": 1593176
  }
}

Deploy with Node.js

const FormData = require('form-data');
const axios = require('axios');
const fs = require('fs');

async function deployApp(zipPath) {
  const formData = new FormData();
  formData.append('file', fs.createReadStream(zipPath));
  formData.append('projectId', 'my-project');
  formData.append('userId', 'user123');

  try {
    const response = await axios.post(
      'https://aiswforge.com/api/spa-deploy/deploy',
      formData,
      { headers: formData.getHeaders() }
    );
    
    console.log('Deployed to:', response.data.deployment.url);
    return response.data.deployment.url;
  } catch (error) {
    console.error('Deployment failed:', error.response?.data?.message);
    throw error;
  }
}

// Usage
deployApp('./dist.zip');

Deploy with Python

import requests

def deploy_app(zip_path):
    url = 'https://aiswforge.com/api/spa-deploy/deploy'
    
    with open(zip_path, 'rb') as f:
        files = {'file': ('app.zip', f, 'application/zip')}
        data = {
            'projectId': 'my-project',
            'userId': 'user123'
        }
        
        response = requests.post(url, files=files, data=data)
        
    if response.status_code == 200:
        deployment_url = response.json()['deployment']['url']
        print(f'Deployed to: {deployment_url}')
        return deployment_url
    else:
        raise Exception(f"Deployment failed: {response.json()['message']}")

# Usage
deploy_app('./dist.zip')

Supported Frameworks

React

Build with npm run build, deploy build/ folder

Vue.js

Build with npm run build, deploy dist/ folder

Next.js

Use output: 'export', deploy out/ folder

Plain HTML

Any static files with index.html at root

Important Notes

  • ZIP must contain index.html at the root level
  • Use relative paths for all assets (e.g., ./style.css, not /style.css)
  • Maximum ZIP size: 100MB
  • All deployments are public - don't include sensitive data

Deploy Endpoint

POST https://aiswforge.com/api/spa-deploy/deploy

Request

  • Method: POST
  • Content-Type: multipart/form-data
  • Required Fields:
    • file - ZIP file containing your built static site
    • projectId - String identifier for your project
    • userId - String identifier for the user

Response Formats

Success (200 OK)
{
  "success": true,
  "deployment": {
    "id": "happy-panda-x7k9",
    "projectId": "my-project",
    "userId": "user123",
    "created": "2025-07-11T23:44:25.039Z",
    "framework": "react",
    "files": 15,
    "totalSize": 1593176,
    "url": "https://happy-panda-x7k9.user-spa.com"
  }
}
Error (400/500)
{
  "error": "Deployment failed",
  "message": "Specific error details"
}

File Structure Requirements

The ZIP file should contain the built/compiled static files with index.html at the root:

React Structure
index.html
favicon.ico
static/
  css/
    main.[hash].css
  js/
    main.[hash].js
Vue.js Structure
index.html
favicon.ico
css/
  app.[hash].css
js/
  app.[hash].js
  chunk-vendors.[hash].js
Plain HTML Structure
index.html
style.css
script.js
assets/
  [images, fonts, etc.]

SPA Deploy Service - LLM Integration Guide

This document provides information for Language Models to deploy static web applications (React, Vue, Next.js, plain HTML/CSS/JS) to a production hosting service.

Service Overview

The SPA Deploy Service allows instant deployment of static websites via a simple API. Each deployment:

  • Gets a unique subdomain: https://[generated-id].user-spa.com
  • Is served globally via AWS CloudFront CDN
  • Supports client-side routing for SPAs
  • Handles static assets (JS, CSS, images, fonts)
  • Is immediately available after deployment

API Endpoint

Deploy a Static Site

Endpoint: POST https://aiswforge.com/api/spa-deploy/deploy

Request:

  • Method: POST
  • Content-Type: multipart/form-data
  • Required Fields:
    • file: ZIP file containing the built static site
    • projectId: String identifier for the project
    • userId: String identifier for the user

Usage Examples

Using cURL

curl -X POST https://aiswforge.com/api/spa-deploy/deploy \
  -F "file=@dist.zip" \
  -F "projectId=my-project" \
  -F "userId=user123"

ZIP File Structure Requirements

The ZIP file should contain the built/compiled static files. The structure depends on the framework:

React (Create React App)

After running npm run build, zip the build folder contents:

index.html
favicon.ico
manifest.json
robots.txt
static/
  css/
    main.[hash].css
  js/
    main.[hash].js
  media/
    [images]

Vue.js

After running npm run build, zip the dist folder contents:

index.html
favicon.ico
css/
  app.[hash].css
js/
  app.[hash].js
  chunk-vendors.[hash].js

Plain HTML/CSS/JS

index.html
style.css
script.js
assets/
  [images, fonts, etc.]

Important Notes for Code Generation

  1. Always include index.html: The root file must be index.html at the top level of the ZIP.
  2. Use relative paths: All asset references should use relative paths:
    <!-- Good -->
    <link href="./styles.css" rel="stylesheet">
    <script src="./script.js"></script>
    
    <!-- Bad -->
    <link href="/styles.css" rel="stylesheet">
    <script src="http://localhost:3000/script.js"></script>
  3. React Router Configuration: For React apps using React Router:
    • BrowserRouter works but requires all routes to return index.html (handled automatically)
    • Consider using HashRouter for simpler deployment
  4. Environment Variables: Don't include sensitive data. The sites are publicly accessible.
  5. File Size Limits: Keep the total ZIP size under 100MB for optimal performance.

Best Practices for LLM Code Generation

  1. Minimize External Dependencies: Use CDN links for libraries when possible
  2. Inline Small Assets: For small apps, consider inlining CSS/JS in index.html
  3. Test Locally First: Ensure the generated code works before deployment
  4. Use Standard Frameworks: React, Vue, and plain HTML/JS are well-supported
  5. Include Error Handling: Add try-catch blocks and user-friendly error messages
  6. Make It Responsive: Include viewport meta tag and responsive CSS

Security Considerations

  • All deployments are publicly accessible
  • No authentication on deployed sites
  • Don't include API keys or secrets
  • HTTPS is enforced for all deployments
  • No server-side code execution (static files only)

This API enables instant deployment of LLM-generated web applications. Each deployment gets a permanent URL that's immediately accessible worldwide via CloudFront CDN.