[PR #13584] server: disable automatic redirects to fix CORS on redirect responses #14281

Open
opened 2026-04-13 00:50:00 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13584
Author: @nathannewyen
Created: 12/30/2025
Status: 🔄 Open

Base: mainHead: fix/cors-redirect


📝 Commits (1)

  • 977cacf server: disable automatic redirects to fix CORS on redirect responses

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 server/routes.go (+4 -0)

📄 Description

Disable RedirectTrailingSlash and RedirectFixedPath in gin to ensure CORS middleware processes all requests.

Without this, paths like //api/tags get redirected to /api/tags with a 301 response that lacks CORS headers, causing browsers to block the redirect.

This is a known issue in gin-gonic where middleware doesn't apply to automatic redirects (see gin-gonic/gin#3857).

Fixes #13420


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13584 **Author:** [@nathannewyen](https://github.com/nathannewyen) **Created:** 12/30/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/cors-redirect` --- ### 📝 Commits (1) - [`977cacf`](https://github.com/ollama/ollama/commit/977cacf0c6a66e46d27f1ab81318bdfb6f928956) server: disable automatic redirects to fix CORS on redirect responses ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+4 -0) </details> ### 📄 Description Disable `RedirectTrailingSlash` and `RedirectFixedPath` in gin to ensure CORS middleware processes all requests. Without this, paths like `//api/tags` get redirected to `/api/tags` with a 301 response that lacks CORS headers, causing browsers to block the redirect. This is a known issue in gin-gonic where middleware doesn't apply to automatic redirects (see [gin-gonic/gin#3857](https://github.com/gin-gonic/gin/issues/3857)). Fixes #13420 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:50:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#14281