Complete guide to set up Ollama backend for the Chrome Extension
Download Ollama from the official website: Download Ollama
Ollama must be running while using the extension. The helper script in the next section will start it automatically for you.
The easiest way to set up Ollama with automatic CORS configuration and LAN access! This script works on macOS, Linux, and Windows.
Step 1: Create the script file ollama-env.sh:
#!/bin/bash
# Cross-platform Ollama environment setup script
# Starts Ollama with proper CORS configuration for browser extensions
# Works on macOS, Linux, and Windows (with Git Bash/WSL)
MODE=$1
# Detect OS
OS="$(uname -s)"
case "${OS}" in
Linux*) OS_TYPE="linux" ;;
Darwin*) OS_TYPE="macos" ;;
MINGW*|MSYS*|CYGWIN*) OS_TYPE="windows" ;;
*) OS_TYPE="unknown" ;;
esac
# Kill existing Ollama processes
if [ "$OS_TYPE" = "windows" ]; then
taskkill //F //IM ollama.exe 2>/dev/null || true
else
pkill -f "ollama serve" 2>/dev/null || true
fi
sleep 1
# Set host to 0.0.0.0 so LAN devices can access it
export OLLAMA_HOST="0.0.0.0"
# Get local IP address (cross-platform)
get_local_ip() {
if [ "$OS_TYPE" = "macos" ]; then
ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo ""
elif [ "$OS_TYPE" = "linux" ]; then
hostname -I 2>/dev/null | awk '{print $1}' || \
ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1 2>/dev/null || echo ""
elif [ "$OS_TYPE" = "windows" ]; then
ipconfig 2>/dev/null | grep -i "IPv4" | head -1 | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1 || echo ""
else
echo ""
fi
}
# Start Ollama based on mode
if [ "$MODE" = "firefox" ]; then
export OLLAMA_ORIGINS="chrome-extension://*,moz-extension://*"
nohup ollama serve > ~/.ollama-firefox.log 2>&1 &
echo "✅ Ollama started with Firefox CORS + LAN access"
else
nohup ollama serve > ~/.ollama-chrome.log 2>&1 &
echo "✅ Ollama started with LAN access"
fi
sleep 2
LOCAL_IP=$(get_local_ip)
echo ""
echo "🌍 Access URLs:"
echo " • http://localhost:11434"
if [ -n "$LOCAL_IP" ]; then
echo " • http://$LOCAL_IP:11434"
fi
echo ""
if [ "$OS_TYPE" = "windows" ]; then
echo "💡 Tip: Ollama is running. To stop it, run:"
echo " taskkill //F //IM ollama.exe"
else
echo "💡 Tip: Ollama is running in the background. To stop it, run:"
echo " pkill -f \"ollama serve\""
fi
echo ""
Step 2: Make it executable and run:
After installation, run a model of your choice:
Once downloaded, you're ready to chat!
Open this in your browser:
Or use curl:
1. Click the ⚙️ Settings icon in the extension popup.
2. You can configure:
Skip this section if the helper script worked! This section explains when and why CORS configuration is needed. Only read if you're troubleshooting or prefer manual setup.
Whether you need to configure CORS depends on your browser:
If you're using Chrome-based browsers and extension version 0.1.3 or later, you likely do not need to set any CORS headers.
Ollama Client uses Chrome's Declarative Net Request (DNR) API to rewrite Origin headers in requests to localhost, which lets it bypass CORS errors without backend changes.
Firefox does not support Chrome's DNR API, so manual configuration is required. This is why the helper script sets OLLAMA_ORIGINS automatically.
To cover both Chrome and Firefox, you can combine origins:
Only use this if the helper script didn't work for you. Follow these platform-specific instructions to manually set OLLAMA_ORIGINS:
1. Edit the plist file:
2. Add inside <key>EnvironmentVariables</key>:
3. Reload the agent:
1. Edit the service file:
2. Add under [Service]:
3. Reload and restart:
1. Press Win + R, type sysdm.cpl, press Enter.
2. Go to Advanced → Environment Variables.
3. Add a new User variable:
4. Restart Ollama.
You can also allow local web apps like this: