AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Connect Local Ollama and LM Studio Models to Novelcrafter Without CORS or Mixed Content Errors

松下祥子 · 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 fiction writers tackling epic fantasy, complex worldbuilding, or sensitive and NSFW themes, keeping creative manuscripts strictly on local hardware is paramount. Cloud AI services present tangible risks: remote telemetry, privacy policy shifts, and the danger of unreleased prose leaking or being ingested into cloud training sets. Novelcrafter offers an industry-leading interface for planning, Codex bible tracking, and AI-assisted prose generation. However, because the Novelcrafter web app operates over secure HTTPS (https://app.novelcrafter.com), connecting it to a local AI server running unencrypted HTTP on localhost routinely triggers two frustrating technical roadblocks: Cross-Origin Resource Sharing (CORS) rejections and browser Mixed Content connection failures.

At 365Finds, our research indicates that writers do not need to compromise their privacy or pay recurring token fees to enjoy Novelcrafter's generative power. Connecting local open-source models via Ollama or LM Studio is entirely achievable once your environment variables, local server flags, and browser security permissions are aligned.

Our commercial and technical judgment is unequivocal:

Here is the comprehensive, step-by-step guide to configuring Ollama, LM Studio, your browser, and Novelcrafter for a flawless, zero-leak offline writing environment.


Why the Connection Fails: CORS and Mixed Content Explained

When you attempt to connect Novelcrafter to your local machine, the browser initiates a network handshake from https://app.novelcrafter.com to http://localhost:11434 (Ollama) or http://localhost:1234 (LM Studio). This request immediately trips two browser security boundaries:

  1. Cross-Origin Resource Sharing (CORS): By default, modern browsers prevent a web application loaded from one domain from reading data from another origin—especially your private localhost. Unless your local model server explicitly emits HTTP response headers that include Access-Control-Allow-Origin: https://app.novelcrafter.com (or a wildcard *), the browser abruptly terminates the connection. Novelcrafter displays a connection refusal or an infinite spinning loader.
  2. Mixed Content / Insecure Content Blocking: Novelcrafter is served over encrypted HTTPS. When an HTTPS page requests resources from an unencrypted HTTP endpoint on your local device, modern browsers classify it as active mixed content. Chromium-based browsers block this traffic by default to protect local network devices, while Safari blocks it outright with no native bypass.

To resolve these errors, you must permit incoming requests on the local server side (CORS) and authorize local HTTP communication on the browser side (Mixed Content).


Method 1: Configuring Ollama for Novelcrafter

Ollama runs as a low-overhead background daemon. By default, it rejects incoming HTTP requests originating from external web domains. You must define the OLLAMA_ORIGINS environment variable to explicitly trust Novelcrafter.

Step 1: Set the CORS Origin Variable

On Windows

On Windows, Ollama launches as a hidden background system tray service. Setting the variable requires updating Windows environment variables:

  1. Completely close Ollama: Right-click the Ollama llama icon in the Windows taskbar system tray and select Quit.
  2. Open Command Prompt (CMD) or PowerShell as an administrator or current user.
  3. Run the following command:
    setx OLLAMA_ORIGINS "https://app.novelcrafter.com"
    
    (Note: If you use other local web tools alongside Novelcrafter, you can use the wildcard value setx OLLAMA_ORIGINS "*" instead).
  4. Re-open Ollama from your Windows Start Menu. The daemon will restart with the new origin whitelist active.

On macOS

On macOS, you can launch Ollama directly from the Terminal with the environment prefix:

  1. Quit the Ollama application from the top macOS menu bar.
  2. Open Terminal and start the server:
    OLLAMA_ORIGINS="https://app.novelcrafter.com" ollama serve
    
  3. To make this permanent so you do not have to type it every session, add the export line to your shell configuration (~/.zshrc or ~/.bash_profile):
    echo 'export OLLAMA_ORIGINS="https://app.novelcrafter.com"' >> ~/.zshrc
    
    Or set it globally across launchd sessions using:
    launchctl setenv OLLAMA_ORIGINS "https://app.novelcrafter.com"
    

On Linux (systemd)

If you installed Ollama as a standard systemd service on Linux:

  1. Open the service drop-in configuration editor:
    sudo systemctl edit ollama.service
    
  2. In the editor window, enter the following lines:
    [Service]
    Environment="OLLAMA_ORIGINS=https://app.novelcrafter.com"
    
  3. Save the file and restart the daemon:
    sudo systemctl daemon-reload
    sudo systemctl restart ollama
    

Step 2: Pre-Pull Your Writing Models

Novelcrafter does not download or manage model files for you. Before establishing the connection, pull your chosen open-source models via the terminal:

ollama pull llama3.1:8b
ollama pull mistral-nemo
ollama pull command-r

Verify that the model is functioning locally by running ollama run llama3.1:8b and testing a quick prompt.


Method 2: Configuring LM Studio for Novelcrafter

LM Studio provides a graphic interface tailored for managing GGUF model files. Depending on the version you have installed (LM Studio Classic or LM Studio Bionic v0.3+), follow the relevant path below.

LM Studio Bionic (Version 0.3.x and Newer)

  1. Launch LM Studio.
  2. Click the Settings (gear icon) located at the bottom of the left sidebar. (If the sidebar is collapsed, expand it via the top-left menu toggle).
  3. Select Local Model API from the settings menu.
  4. Toggle Local API Server to ON.
  5. Toggle CORS to ON. This allows external web clients like app.novelcrafter.com to communicate with your local port.
  6. Verify the Base URL display: The host is typically 127.0.0.1 and the port is 1234.

LM Studio Classic

  1. Launch LM Studio and ensure the application is set to Power User or Developer Mode (selectable via the dropdown in the bottom-left corner).
  2. Click the Developer Settings / Local Server icon (<->) on the left navigation bar.
  3. In the right-hand Server Settings panel:
    • Check the box for Enable CORS.
    • Check the box for Just-in-Time Model Loading. This setting is critical: it lets Novelcrafter detect and display every model downloaded to your disk, automatically loading weights into VRAM only when Novelcrafter sends a generation request.
  4. Click the toggle next to Status to switch it to Running.
  5. Confirm the endpoint reads http://localhost:1234 or http://127.0.0.1:1234.

Method 3: Unlocking Browser Mixed Content & Shield Settings

Even when your local AI engine has CORS enabled, Chromium-based browsers may still halt requests due to HTTPS-to-HTTP mixed content policies or strict ad-blocking shields.

1. Allow Insecure Content in Google Chrome and Microsoft Edge

  1. Open your browser and navigate to https://app.novelcrafter.com.
  2. Look at the address bar: click the Site Information / Tune icon (sliders or padlock) located immediately to the left of app.novelcrafter.com.
  3. Select Site settings.
  4. In the permissions list, locate Insecure content.
  5. Change the setting from Block (default) to Allow.
  6. Return to your Novelcrafter tab and click Reload.

2. Configure Brave Browser

Brave's built-in tracker protection actively blocks cross-network and unencrypted local traffic.

  1. In the Novelcrafter tab, click the Brave Lion Shield icon to the right of the address bar.
  2. Toggle Shields to DOWN (OFF) for app.novelcrafter.com.
  3. If issues persist, verify in brave://settings/shields that local network device access is permitted.

3. Safari Compatibility Notice

Safari enforces strict WebKit security that outright denies active mixed content calls from an HTTPS domain to an unencrypted http://localhost port. There is no user-accessible toggle to bypass this. Authors using macOS must use Chrome, Brave, Edge, or Firefox when integrating local models with Novelcrafter.


Connecting the Local Endpoint in Novelcrafter

Once your local server is broadcasting and your browser is configured, link the endpoint inside Novelcrafter:

  1. Log in to https://app.novelcrafter.com.
  2. Click your user avatar in the bottom-left corner and select AI Connections.
  3. Under the available connection catalog, locate either Ollama or LM Studio and click Add.
  4. Review the endpoint parameters:
    • For Ollama: Host should be localhost (or 127.0.0.1), Port should be 11434.
    • For LM Studio: Host should be localhost (or 127.0.0.1), Port should be 1234.
  5. If the browser displays a prompt asking: "app.novelcrafter.com wants to access devices on your local network", click Allow.
  6. Click the Refresh button inside the connection card. If configured properly, a green checkmark will appear, and your pulled/downloaded models will populate the Supported Models dropdown.

Critical Post-Connection Settings: Collections and Prompt Tuning

Establishing a physical network handshake is only half the battle. To actually use your local models in Novelcrafter's Write tab, Chat, or Workshop, you must configure model collections and prompt parameters.

1. Adding Local Models to Model Collections

Novelcrafter separates AI connections from Model Collections. Novelcrafter's default cloud model collections do not automatically include local models, leaving them greyed out or missing in your project editor.

2. Prioritizing Connection Order

If you maintain multiple active connections (for instance, OpenRouter for quick brainstorming alongside LM Studio for private prose), Novelcrafter uses connection priority when resolving model names. In the AI Connections list, click and drag your local connection card to the very top. This guarantees Novelcrafter routes requests to your local GPU rather than attempting a cloud fallback.

3. Disabling System Messages for Specific Architectures

Certain open-source model families—most notably Google's Gemma and Gemma 2—throw errors such as: Error running prompt 'user/assistant/user/assistant' while running a prompt These models reject separate system message blocks in the OpenAI API schema.

4. Tuning Context Length vs. VRAM Capacity

Novelcrafter injects rich manuscript context: Codex character entries, world notes, relationship states, and recent scene beats. If your local context window is set too high, your GPU will overflow VRAM into system RAM, slowing generation to a crawl or crashing the server.

GPU Hardware TierRecommended Model ClassesContext Window TargetQuantization Sweet Spot
8 GB VRAM (e.g., RTX 3060 Laptop, RTX 4060)7B – 8B parameters (Llama 3.1 8B, Mistral 7B)4,096 – 8,192 tokensQ4_K_M
12 GB – 16 GB VRAM (e.g., RTX 4070, 4080, Apple M2/M3 24GB)8B – 14B parameters (Mistral Nemo 12B, Gemma 2 9B)8,192 – 16,384 tokensQ5_K_M or Q6_K
24 GB+ VRAM (e.g., RTX 3090, RTX 4090, Apple M-Max 64GB+)27B – 70B parameters (Command R 35B, Llama 3.3 70B)16,384 – 32,768 tokensQ4_K_M or Q5_K_M

[!TIP] 365Finds Recommendation for Fiction Prose: For writers with 12GB to 16GB of VRAM, we strongly recommend Mistral Nemo 12B (Instruct) or Llama 3.1 8B (Instruct) quantized at Q5_K_M. They strike the ideal balance between literary prose rhythm, adherence to complex Codex scene constraints, and brisk inference speeds exceeding 25 tokens per second.


Troubleshooting Quick Reference

Issue EncounteredRoot CauseExact Remedy
TypeError: Failed to fetchLocal server not running or CORS blockedVerify LM Studio/Ollama is running; recheck OLLAMA_ORIGINS or LM Studio CORS checkbox.
Endless spinning loader in NovelcrafterMixed Content blocked by browserOpen Site Settings in Chrome/Edge; set Insecure content to Allow.
Local models missing from dropdownModel files not pulled or JIT disabledIn LM Studio, enable Just-in-Time Model Loading; in Ollama, run ollama pull <model> in terminal.
Model selectable but greyed outModel not in current collectionAdd the local model to an active Model Collection in Novelcrafter settings.
Extreme lag / System freeze during generationVRAM overflowed into system RAMReduce context window in model settings or switch from a Q8/FP16 quant to Q4_K_M / Q5_K_M.

By establishing proper CORS headers, unblocking browser insecure content policies, and setting up dedicated Model Collections, fiction authors achieve the gold standard of literary technology: the fluid structuring, beat tracking, and Codex depth of Novelcrafter, backed by 100% private, offline, and subscription-free generative intelligence.


References