You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unsupported protocol "ttp". http and https are supported
By debugging and following the code, the scheme has been overwritten to "ttp" at this line: https://github.com/gofiber/fiber/blob/master/middleware/proxy/proxy.go#L131 , since at some point the addr variable has changed to "ttp://xxxxx" (without the leading "h"), the parsed scheme changed to "ttp". It seems related to the memory allocation, the problem will be gone, if in my code I either:
change the fiber config to use Immutable: true, or
change path := c.OriginalURL() to path := utils.CopyString(c.OriginalURL()) .
But since the code above doesn't violate fiber's rule:
As a rule of thumb, you must only use context values within the handler, and you must not keep any references.
Even if I don't use Immutable: true or utils.CopyString, the problem shouldn't be there.
Bug Description
I am making a simple proxy that you can append the proxied url after /, for example, you can request http://localhost:3333/http://ip-api.com/json/1.1.1.1 , which will proxy request to http://ip-api.com/json/1.1.1.1.
Here is my code:
When I request the url like: http://localhost:3333/http://ip-api.com/json/1.1.1.1 , it will show this error:
By debugging and following the code, the scheme has been overwritten to "ttp" at this line: https://github.com/gofiber/fiber/blob/master/middleware/proxy/proxy.go#L131 , since at some point the
addr
variable has changed to "ttp://xxxxx" (without the leading "h"), the parsed scheme changed to "ttp". It seems related to the memory allocation, the problem will be gone, if in my code I either:Immutable: true
, orpath := c.OriginalURL()
topath := utils.CopyString(c.OriginalURL())
.But since the code above doesn't violate fiber's rule:
Even if I don't use
Immutable: true
orutils.CopyString
, the problem shouldn't be there.Also, this bug doesn't exist when I was using version v2.10.0, which doesn't have these 3 lines: https://github.com/gofiber/fiber/blob/master/middleware/proxy/proxy.go#L130
How to Reproduce
Copy the above code and run it with fiber v2.36.0, then visit: http://localhost:3333/http://ip-api.com/json/1.1.1.1 .
You should be able to see the error:
I can reproduce this in my 3 laptops: Macbook m1, Mackbook m2 and Macbook Intel.
Expected Behavior
The error shouldn't be there (the scheme shouldn't be incorrectly overwritten) even without "Immutable: true" config or CopyString
Fiber Version
v2.36.0
Code Snippet (optional)
See above
Checklist:
The text was updated successfully, but these errors were encountered: