AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Connect Ollama and LM Studio to Novelcrafter Without CORS Errors

Ana Flávia Magalhães · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

For novelists and genre writers, moving generative AI offline represents creative autonomy: zero API token bills, total manuscript confidentiality without cloud telemetry, and complete freedom from puritanical content filters when writing dark fantasy, psychological thrillers, or explicit romance. Novelcrafter is arguably the premier workspace for long-form fiction authors, offering an unparalleled narrative engine with its Codex story bible, scene beat manager, and custom prompt builder.

However, running local models like Llama 3, Mistral, Qwen 2.5, or Command R inside Novelcrafter presents an immediate technical roadblock: Cross-Origin Resource Sharing (CORS) connection failures.

Because Novelcrafter runs in a secure HTTPS browser sandbox (https://app.novelcrafter.com), modern browser security blocks cross-origin fetch requests directed to unencrypted local machine ports (http://localhost:11434 or http://localhost:1234). Writers attempting this setup routinely encounter opaque "Failed to fetch," "Network Error," or empty model dropdowns.

At 365Finds, our technical assessment is clear: running local models inside Novelcrafter is both practical and sustainable for fiction production—provided you properly bridge the browser-to-local security perimeter and aggressively expand model context parameters. Here is the comprehensive configuration playbook to defeat CORS errors across Ollama and LM Studio, alongside our architectural recommendations for fiction generation.


Why the CORS Error Happens in Novelcrafter

To solve the connection failure, authors must understand the browser handshake:

  1. Origin Disparity: Novelcrafter operates over secure HTTPS from https://app.novelcrafter.com. Your local model backends run over plain HTTP on loopback IP addresses (127.0.0.1 or localhost).
  2. Preflight Rejection: When Novelcrafter’s web interface attempts to query your local server (such as probing GET /api/tags on Ollama or GET /v1/models on LM Studio), the web browser sends a preflight OPTIONS request.
  3. Missing Response Headers: Unless the local service explicitly replies with Access-Control-Allow-Origin: https://app.novelcrafter.com (or a wildcard *), the browser instantly terminates the request at the network stack. Novelcrafter never sees the response, leading to a silent hang or a red error notification.

Fixing this requires configuring your local inference runner to explicitly trust Novelcrafter's origin domain.


Configuring Ollama: System-Level Origin Whitelisting

Ollama runs as a low-overhead background daemon. Because its HTTP server refuses web requests by default, you must inject the OLLAMA_ORIGINS environment variable.

1. Windows Setup

Windows executes Ollama as a startup background task accessible via the system tray.

  1. Shut Down Ollama: Right-click the Ollama llama icon in your Windows Taskbar System Tray and select Quit.
  2. Set the Persistent Environment Variable:
    • Open PowerShell or Command Prompt as your standard user.
    • Run the following command:
      setx OLLAMA_ORIGINS "https://app.novelcrafter.com"
      
    • Alternative (GUI): Open the Start Menu, search for Edit environment variables for your account, click New under User Variables, set Variable Name to OLLAMA_ORIGINS, and Variable Value to https://app.novelcrafter.com (or * if you use multiple local tools).
  3. Relaunch Ollama: Launch Ollama again from the Start Menu. It will now boot with cross-origin headers active.

2. macOS Setup

On macOS, GUI applications started by the operating system do not inherit .zshrc shell variables. You have two reliable launch options:

3. Linux (Systemd Service) Setup

Linux installations typically run Ollama via systemd:

  1. Open the systemd override editor:
    sudo systemctl edit ollama.service
    
  2. Insert the following block under the Service definition:
    [Service]
    Environment="OLLAMA_ORIGINS=https://app.novelcrafter.com"
    
  3. Save the file and reload the daemon:
    sudo systemctl daemon-reload
    sudo systemctl restart ollama
    

Configuring LM Studio: The UI-Native Local Server

LM Studio provides the friendliest visual environment for authors running quantized GGUF models. It includes a native graphical toggle to eliminate CORS restrictions.

  1. Open LM Studio: Launch the desktop application.
  2. Navigate to Local Server Settings:
    • Click the Developer / Local Server tab (represented by the double-bracket or server icon on the left navigation bar).
    • Ensure the app is in Developer/Power User mode if prompted.
  3. Activate Server Configuration:
    • Locate the Server Settings card on the right or top sidebar.
    • Toggle Enable CORS to ON. (This instructs the built-in HTTP server to emit all necessary permissive CORS headers).
    • Toggle Just-in-Time Model Loading to ON. (This is critical: it lets Novelcrafter discover your entire local library of downloaded GGUFs without forcing you to pre-load a 16GB model into VRAM ahead of time).
  4. Set Port and Network Binding:
    • Keep the default port at 1234.
    • Ensure the server binds to 127.0.0.1 (Localhost) if running on the same computer.
  5. Start the Engine: Click Start Server. The console log will confirm that the OpenAI-compatible REST server is active on http://localhost:1234.

Connecting Local Runners Inside Novelcrafter

Once your runner is broadcasting with CORS permissions, configure Novelcrafter's AI Provider hub:

  1. Log into https://app.novelcrafter.com and open your Project.
  2. Navigate to Account Settings (gear icon) -> AI Connections / Providers.
  3. Click Add Connection and pick your respective runner:
Connection TypeEndpoint URLAPI Key FieldModel Population
Ollamahttp://localhost:11434Leave blankAutomatic click on dropdown
LM Studiohttp://localhost:1234/v1 (or http://localhost:1234)Any text (e.g., lm-studio)Populates from downloaded GGUFs
OpenAI Compatiblehttp://localhost:1234/v1Any placeholder textManual Model ID matching local alias

Click Test Connection or refresh the model list. If CORS was configured properly, your downloaded open-source models will appear immediately in the dropdown list.

Crucial Browser Compatibility Caveat


The Critical Fiction Trap: Expanding Context Limits (num_ctx)

Getting the green connection checkmark is only half the battle. The most devastating silent failure fiction writers face when deploying local LLMs is context starvation.

The Problem

By default, Ollama and LM Studio often initialize models with conservative context ceilings (such as 2,048 or 4,096 tokens) to conserve system memory. However, Novelcrafter’s prose engine dynamically packages:

When this payload exceeds 4k tokens on an unconfigured local model, the runner silently truncates your history or fails with an out-of-memory exception. The author experiences amnesia: characters forget recent dialogue, narrative pacing breaks down, or the model loops repetitive phrases.

1. Extending Context in Ollama (Custom Modelfile)

To permanently lock an expanded context window into your chosen writing model, create an Ollama Modelfile:

  1. Create a plain text file named Modelfile on your desktop.
  2. Add your base model and the target context parameter (e.g., 16,384 or 32,768 tokens):
    FROM llama3.1:8b
    PARAMETER num_ctx 16384
    
  3. Open Terminal/CMD and compile your dedicated authoring model:
    ollama create llama3.1-novel -f Modelfile
    
  4. In Novelcrafter, select your new llama3.1-novel model.

2. Extending Context in LM Studio

  1. In LM Studio, click on your downloaded model in the Local Server or Chat view.
  2. In the right-hand Model Loader Settings, look for Context Length.
  3. Manually increase the slider from 2048 or 4096 up to 16384 (or 32768 if your VRAM allows).
  4. Reload the model into memory.

3. Tuning Novelcrafter Custom Model Parameters

In Novelcrafter’s Custom Model configuration pane, mirror these hardware limits:


Hardware Reality and the 365Finds Institutional Verdict

Local fiction writing is liberating, but commercial realism demands honest appraisal of hardware overhead. Long context generation in local models demands dedicated VRAM for the KV (Key-Value) Cache:

Hardware ClassTypical VRAMRecommended ModelsPractical Context Ceiling
Entry Level8 GB (RTX 3060/4060 laptop)Llama 3.1 8B Q4_K_M; Mistral 7B Q48,192 tokens max
Mid-Tier Workhorse12 GB – 16 GB (RTX 4070 / Apple M-series 24GB)Llama 3.1 8B Q8; Qwen 2.5 14B Q416,384 – 32,768 tokens
Enthusiast / Studio24 GB+ (RTX 3090/4090 / Apple M-series 64GB+)Qwen 2.5 32B Q4; Command R 35B Q432,768+ tokens (Full Codex load)

365Finds Recommendation: The Hybrid Author Pipeline

At 365Finds, we advise fiction authors not to treat local AI as an all-or-nothing dogmatic choice.

While open-weight 8B models have made remarkable strides, they still struggle with intricate, multi-threaded plot resolutions, subtextual irony, and vast cross-book continuity compared to premier frontier models like Claude 3.5 Sonnet or GPT-4o.

The winning strategy is a Hybrid Author Pipeline:

  1. Use Cloud Frontier Models for High-Level Architecture: Utilize Claude 3.5 Sonnet via OpenRouter for outlining 30-chapter story arcs, architecting the series Codex, and performing structural developmental editing.
  2. Route Uncensored & High-Volume Beats to Local Runners: Connect Novelcrafter to your CORS-configured Ollama or LM Studio instance for drafting gritty fight sequences, explicit romantic scenes, rapid sentence completions, and unlimited zero-cost prose brainstorming.

By mastering the OLLAMA_ORIGINS flag and LM Studio’s CORS toggle, you retain total sovereign control over your sensitive manuscripts while transforming Novelcrafter into an unrestricted, cost-free creative engine.


References