[PR #15] Add CORS middleware support #21

Open
opened 2026-03-01 14:36:52 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amitshekhariitbhu/go-backend-clean-architecture/pull/15
Author: @pinyuho
Created: 7/4/2023
Status: 🔄 Open

Base: mainHead: add-cors-middleware-support


📝 Commits (1)

  • dc3ae36 Add CORS middleware support

📊 Changes

2 files changed (+29 additions, -2 deletions)

View changed files

api/middleware/cors_middleware.go (+23 -0)
📝 api/route/route.go (+6 -2)

📄 Description

Hi! I really appreciate your work. It helped a lot, thank you.
However, I encountered some bugs when developing on cross origin platforms(especially calling the API from local React App frontend. e.g., localhost:3000).

Error message on Chrome DevTools:

Access to XMLHttpRequest at 'http://localhost:8080/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Hope this PR would help:)


🔄 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/amitshekhariitbhu/go-backend-clean-architecture/pull/15 **Author:** [@pinyuho](https://github.com/pinyuho) **Created:** 7/4/2023 **Status:** 🔄 Open **Base:** `main` ← **Head:** `add-cors-middleware-support` --- ### 📝 Commits (1) - [`dc3ae36`](https://github.com/amitshekhariitbhu/go-backend-clean-architecture/commit/dc3ae3636a70b461e0ca7007709c2d0b54cc6bc6) Add CORS middleware support ### 📊 Changes **2 files changed** (+29 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `api/middleware/cors_middleware.go` (+23 -0) 📝 `api/route/route.go` (+6 -2) </details> ### 📄 Description Hi! I really appreciate your work. It helped a lot, thank you. However, I encountered some bugs when developing on cross origin platforms(especially calling the API from local React App frontend. e.g., `localhost:3000`). Error message on Chrome DevTools: > Access to XMLHttpRequest at 'http://localhost:8080/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Hope this PR would help:) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-backend-clean-architecture#21
No description provided.