Deploy Typesense CORS

browser search clients with CORS on

Deploy Typesense CORS

Just deployed

Deploy and Host self hosted Typesense CORS (Open-Source Instant Search) on Railway

Typesense CORS isn't a separate binary or plugin — it's the same open-source Typesense engine started with --enable-cors so browser search clients like InstantSearch.js can hit your Railway-hosted node without blocked preflight requests.

About Hosting Typesense CORS open-source software on Railway (self hosted Typesense template)

On Railway you get a single Typesense service, a volume at /data, and a public URL on port 8108. Flip on --enable-cors in the start command and InstantSearch.js can call the API from the browser without an nginx CORS proxy in between.

Why Deploy Typesense CORS, the Algolia alternative on Railway (Railway Free Trial)

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Typesense CORS on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Railway vs Other Hosting Providers and VPS for Typesense CORS self hosting

ProviderCORS setupPersistent storage for /dataCost for small nodeBest for
Railway--enable-cors flag in commandBuilt-in volumes, auto-attachedLow single-digit to low-teens USD/monthManaged PaaS with Git deploys
DigitalOceanManual Dockerfile/droplet + flagBlock storage manual create/mount$6–12/month + $1–2 volumeSolo devs OK with SSH
AWSEC2 + EBS, IAM, still a flagEBS easy but pricier$15–30/month t3.small + gp3Teams already in AWS
HetznerVPS + Docker, same flagLocal NVMe included€4–8/month CX11/CX21Cost-sensitive EU projects

Railway's edge: click "Add Volume," set /data, and it survives redeploys. Hetzner is cheaper but you manage updates and backups yourself.

Common Use Cases for hosted Typesense CORS

  • Public search widgets — docs, blogs, product finders where the browser talks directly to Typesense.
  • Headless ecommerce — Shopify Hydrogen, Next.js storefronts need client-side facet search without a backend proxy.
  • Prototyping before a backend — point a static HTML file at your Railway URL, test relevance, add server later.

Dependencies for Typesense CORS Docker hosted on Railway

The self-hosted container needs very little. The official image bundles everything, and the only external dependency is a persistent volume so your index survives redeploys. You also need an API key, which Railway injects as an environment variable. Beyond that, CORS is just a startup flag.

Deployment Dependencies for Managed Typesense CORS Service (Browser Instant Search)

Typesense Cloud handles CORS, volumes, and keys for you. You still need a scoped key (not admin) and point your client at the cloud URL. Cloud enables CORS automatically, so you skip --enable-cors — the tradeoff is less control and zero infrastructure.

Implementation Details for Typesense CORS (Using Typesense official docker image)

On Railway, create a Docker service and set the start command to --data-dir /data --api-key=$TYPESENSE_API_KEY --enable-cors. Attach a volume at /data (1GB minimum). Health check: GET /health on port 8108.

How does Typesense CORS compare against other Browser Search APIs platforms

Browser search APIs split into those built for client-side queries (Typesense, Meilisearch) and those needing proxies (Elasticsearch). Algolia is cloud-only. Typesense Cloud is the same engine but managed.

Typesense CORS vs Algolia (Algolia Alternative)

Algolia handles CORS transparently because every request goes to their servers. Typesense needs --enable-cors once at deploy.

Typesense CORS vs Meilisearch (Meilisearch Alternative)

Meilisearch has CORS enabled by default, so it's slightly simpler. Typesense's scoped keys are more granular (restrict by collection, action, search parameters). Both offer excellent instant search and typo tolerance. Typesense's InstantSearch adapter is more mature for faceted ecommerce, while Meilisearch's admin UI is prettier.

Typesense CORS vs Elasticsearch (Elasticsearch Alternative)

Elasticsearch isn't built for browser clients — you need a proxy to add CORS headers, and the JS client is heavy. Typesense's entire purpose is lightweight, direct browser queries. Elasticsearch shines for log analytics and complex aggregations; for a product search box, Typesense is far simpler and cheaper to run on Railway.

Typesense CORS vs Typesense Cloud (Typesense Cloud Alternative)

Typesense Cloud runs the same binary with CORS already on, billed by dedicated RAM and vCPU (about $21.60/month for a 0.5 GB burst node).

How to use Typesense CORS (the OSS Browser Instant Search)?

Start the official image with the --enable-cors flag. The server then adds Access-Control-Allow-Origin headers so browser clients can call the Typesense API directly.

On the browser side, use the Typesense InstantSearch adapter with a search-only API key. Point the client to http://your-host:8108. No backend proxy is required. Create a collection, index documents, then wire the adapter to the same host and search-only key.

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "SEARCH_ONLY_KEY",
    nodes: [{ host: "your-host", port: 8108, protocol: "http" }]
  },
  additionalSearchParameters: { query_by: "title" }
});

Browser requests go directly to Typesense. CORS is enabled globally; restrict access at the network layer or with scoped keys.

How to self host Typesense CORS on other VPS Services (Typesense CORS self hosting guide)

Self-hosting uses the official Docker image; no separate application build is required. Enable CORS with a server flag and mount /data for snapshots.

Clone the Repository

For a minimal setup, create a git repository containing a docker-compose.yml. If you already have an infrastructure config repo, clone that. The Typesense server itself comes from the upstream image and does not need source cloning.

git clone your-config-repo
cd your-config-repo

Install Dependencies

Install Docker Engine and the Compose plugin on the VPS.

sudo apt update
sudo apt install docker.io docker-compose-v2

The typesense/typesense:30.2 image bundles all runtime dependencies.

Configure Environment Variables

Create a .env file in the same directory as the compose file.

TYPESENSE_API_KEY=replace-with-long-random-string
TYPESENSE_DATA_DIR=/data
TYPESENSE_ENABLE_CORS=true
TYPESENSE_PORT=8108

In docker-compose.yml, pass the flag directly:

services:
  typesense:
    image: typesense/typesense:30.2
    command: ["--data-dir", "/data", "--api-key", "${TYPESENSE_API_KEY}", "--enable-cors"]
    ports:
      - "8108:8108"
    volumes:
      - typesense-data:/data
    restart: unless-stopped
volumes:
  typesense-data:

Start the Typesense CORS Application

docker compose up -d
curl http://localhost:8108/health

The health endpoint returns {"ok":true}. Create collections and scoped keys through the API using X-TYPESENSE-API-KEY: $TYPESENSE_API_KEY.

Official Pricing of Typesense CORS (Typesense CORS pricing)

Typesense OSS is free under GPL-3.0. The typesense/typesense:30.2 image has no download fee. CORS is a server flag, not a paid feature. Typesense Cloud is a managed option; its entry-level 0.5GB burst cluster costs about $21.60/mo.

Typesense CORS cloud vs self hosted comparison (Pricing, features, costs, and more)

Typesense Cloud manages backups, monitoring, upgrades, and scaling. The 0.5GB burst tier starts near $21.60/mo. Self-hosting on Railway runs the same engine at single-digit to low-teens USD per month, but you handle snapshots, key rotation, and OS updates.

Monthly cost of self hosting Typesense CORS on Railway

Railway’s $5 GitHub trial credit can cover initial testing. A typical deployment with 512MB RAM, 0.5 vCPU, and 1GB disk costs roughly $5-10/mo. Search-heavy bursts may reach $10-15/mo. A persistent volume for /data adds about $0.10/GB/mo. Most single-index deployments stay under $10/mo outside trial.

System Requirements for Hosting Typesense CORS on a VPS

Minimum for small indexes under 10k documents: 1 vCPU, 512MB RAM, 2GB disk. For 100k documents, allocate 1-2GB RAM and 4GB disk. Use a Linux host with Docker installed. Expose port 8108. Add swap if RAM is tight, but avoid relying on swap for production search.

Frequently Asked Questions (FAQs)

Do I need a reverse proxy for CORS?

No. Typesense has built-in CORS support via the --enable-cors flag, so you can serve browser requests directly from the Railway container without an additional reverse proxy.

Which flag turns CORS on?

Use --enable-cors as a command argument in your Railway service configuration. For example, start Typesense with --enable-cors --api-key=$TYPESENSE_API_KEY --data-dir=/data.

What happens if I use the admin API key in the browser?

Using the admin API key in client-side code exposes full write and delete permissions. Create a search-only API key from the Typesense API and use that in the browser instead.

Does --enable-cors work with InstantSearch.js?

Yes. Once --enable-cors is set and you supply a search-only API key, InstantSearch.js can connect directly to your Typesense instance on Railway without any proxy.

How do I confirm CORS headers from curl?

Send a preflight or simple request with an Origin header, for example: curl -I -H "Origin: http://localhost:3000" https://your-app.up.railway.app:8108/health. Look for Access-Control-Allow-Origin in the response.


Template Content

More templates in this category

View Template
Typesense vs Meilisearch
self-hosted Typesense vs Meilisearch

onepush
0
View Template
Betterlytics
Betterlytics is a cookieless analytics platform GDPR-compliant.

OpenSource Templates
27
View Template
Finance Tracker
Private multi-user household finance ledger with budgets and CSV import.

wotonews
0