Description
I want to redirect to another website using Gin, but i'm getting this behavior. Maybe i'm missing something?
How to reproduce
Code snippet:
ctx.Redirect(http.StatusPermanentRedirect, "https://www.google.it")
Expectations
Redirect to https://www.google.it
Actual result
Redirect to http://localhost:portnumber/www.google.it
Environment
- go version: 1.21.5
- gin version (or commit ref): 1.9.1
- operating system: Windows
Comment From: IAmRiteshKoushik
Hi @8lall0 , for redirection using the Gin framework, the documentation is a great place to refer. Redirects | Gin Framework is a good place to start. It offers some simple examples which seem to be the solution to your problem.
Comment From: brandon1024
@8lall0 I can't reproduce what you're seeing. Can you provide more information/context?
Here's what I got:
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Content-Type: text/html; charset=utf-8
< Location: http://www.google.com/
< Date: Tue, 23 Jan 2024 19:42:54 GMT
< Content-Length: 57
<
<a href="http://www.google.com/">Moved Permanently</a>.
And the code:
func doIt(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")
}
Comment From: 8lall0
Hi, at the end was a problem with my browser that cached a wrong permanent redirect.
Closing issue, thank you for the patience.