The exchange call's provided code shouldn't ever travel through a proxy server

Hi Team,

Please review the below code. The exchange call’s provided code shouldn’t ever travel through a proxy server.

func proxyHandler(c *gin.Context) {
	remote, err := url.Parse("office365 URL")
	if err != nil {
		// Handle error
		c.AbortWithError(http.StatusInternalServerError, err)
		return
	}
	proxy := httputil.NewSingleHostReverseProxy(remote)
	proxy.Director = func(req *http.Request) {
		req.Header = c.Request.Header
		req.Header.Set("Authorization", "Token")
		req.Host = remote.Host
		req.URL.Scheme = remote.Scheme
		req.URL.Host = remote.Host
		req.URL.Path = c.Param("proxyPath")
	}
	proxy.ServeHTTP(c.Writer, c.Request)
}

Please can you suggsted guys. where i did mistake the above code.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.