agentsclimarketplace

Tauri cors origins setup

Skill kjuhwa/skills-hub/skills/fastapi/tauri-cors-origins-setup

Allow a FastAPI backend to accept requests from the full range of Tauri webview origins on macOS, Windows, and Linux, plus Vite dev.From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill tauri-cors-origins-setup

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.6 KB, 533 tokens by cl100k_base, as published. Nobody here has run it

Tauri CORS origins setup

When to use

A FastAPI sidecar talks to a Tauri webview in dev and in production across all three desktop platforms. You keep seeing CORS errors that only reproduce on one OS, or only in dev.

Steps

  1. Seed the allowed origins list with dev + every Tauri webview origin form:
    • http://localhost:5173 and http://127.0.0.1:5173 (Vite dev server)
    • http://localhost:<server_port> and http://127.0.0.1:<server_port> for the backend's own port, in case the frontend is embedded behind it
    • tauri://localhost (Tauri on macOS)
    • https://tauri.localhost (Tauri on Windows/Linux in most versions)
    • http://tauri.localhost (Tauri on Windows in some builds)
  2. Accept runtime extension via an env var like VOICEBOX_CORS_ORIGINS="https://..., https://...". Split on comma, strip each entry, and extend the default list. This lets power users run with a reverse proxy or remote access without a rebuild.
  3. Install CORSMiddleware with allow_origins= the computed list, allow_credentials=True, allow_methods=["*"], allow_headers=["*"]. Because Tauri origins are not wildcardable (scheme varies), do NOT use allow_origins=["*"] — wildcards are incompatible with allow_credentials=True per spec.
  4. Keep the CORS setup in a single _configure_cors(app) helper invoked by the app factory. New dev ports or platform quirks land in one place.

Counter / Caveats

  • The three tauri.localhost variants are all real — different Tauri versions and platforms use different schemes. Don't drop any of them "to clean up" until you've tested the matrix.
  • allow_origins=["*"] with allow_credentials=True silently disables credentials in modern browsers. Use the explicit list even if it feels long.
  • If you add a new origin via the env var on production, remember it must include the scheme (https://example.com, not example.com).
  • In dev, Vite's port may change if 5173 is taken; consider adding 5174/5175 or reading Vite config to extend the list.

Source references: backend/app.py (_configure_cors).

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,871. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.