Sitelet https://web.archive.org/web/20200930104440/https://github.com/gin-gonic/gin/issues/2458
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

307 Temporary Redirect - CORS header ‘Access-Control-Allow-Origin’ missing #2458

Open
khanakia opened this issue Aug 7, 2020 · 3 comments · May be fixed by #2477
Open

307 Temporary Redirect - CORS header ‘Access-Control-Allow-Origin’ missing #2458

khanakia opened this issue Aug 7, 2020 · 3 comments · May be fixed by #2477

Comments

@khanakia
Copy link

@khanakia khanakia commented Aug 7, 2020 •

Description

How to reproduce

I am sending an AJAX request which has trailing slash redirect but it does not redirects because of CORS issue. I dig the code more and then i found that gin.go file has redirectRequest function github.com/gin-gonic/gin/gin.go if i add the the CORS header then the whole request works fine as you can see the screenshot under EXPECTATION section.

How to resolve the issue without modifying the GIN core file ?

func redirectRequest(c *Context) {

        // CODE INSERTED ==================
	c.Writer.Header().Set("Access-Control-Allow-Origin", c.Request.Header.Get("Origin"))

	req := c.Request
       ....
}

Expectations

Screenshot 2020-08-07 at 9 31 25 PM

Actual result

Screenshot 2020-08-07 at 9 26 07 PM

Screenshot 2020-08-07 at 9 25 54 PM

Environment

  • go version: 1.14
  • gin version (or commit ref): v1.6.3
  • operating system: OSX
@khanakia
Copy link
Author

@khanakia khanakia commented Aug 16, 2020

Any update ?

@unbyte
Copy link

@unbyte unbyte commented Aug 22, 2020

@khanakia
Copy link
Author

@khanakia khanakia commented Aug 22, 2020

@unbyte i did already test that git contrib cors. CORS are not working for Temporary Redirects that's why i have to add it manually.

@unbyte unbyte linked a pull request that will close this issue Aug 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.