mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #11249 from bergquist/legacy_render_urls
Avoid redirecting internal rendering requests
This commit is contained in:
commit
105f6ff88c
@ -72,7 +72,9 @@ func RenderToPng(params *RenderOpts) (string, error) {
|
|||||||
localDomain = setting.HttpAddr
|
localDomain = setting.HttpAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s:%s/%s", setting.Protocol, localDomain, setting.HttpPort, params.Path)
|
// &render=1 signals to the legacy redirect layer to
|
||||||
|
// avoid redirect these requests.
|
||||||
|
url := fmt.Sprintf("%s://%s:%s/%s&render=1", setting.Protocol, localDomain, setting.HttpPort, params.Path)
|
||||||
|
|
||||||
binPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, executable))
|
binPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, executable))
|
||||||
scriptPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, "render.js"))
|
scriptPath, _ := filepath.Abs(filepath.Join(setting.PhantomDir, "render.js"))
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"gopkg.in/macaron.v1"
|
"gopkg.in/macaron.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,9 +37,14 @@ func RedirectFromLegacyDashboardUrl() macaron.Handler {
|
|||||||
func RedirectFromLegacyDashboardSoloUrl() macaron.Handler {
|
func RedirectFromLegacyDashboardSoloUrl() macaron.Handler {
|
||||||
return func(c *m.ReqContext) {
|
return func(c *m.ReqContext) {
|
||||||
slug := c.Params("slug")
|
slug := c.Params("slug")
|
||||||
|
renderRequest := c.QueryBool("render")
|
||||||
|
|
||||||
if slug != "" {
|
if slug != "" {
|
||||||
if url, err := getDashboardUrlBySlug(c.OrgId, slug); err == nil {
|
if url, err := getDashboardUrlBySlug(c.OrgId, slug); err == nil {
|
||||||
|
if renderRequest && strings.Contains(url, setting.AppSubUrl) {
|
||||||
|
url = strings.Replace(url, setting.AppSubUrl, "", 1)
|
||||||
|
}
|
||||||
|
|
||||||
url = strings.Replace(url, "/d/", "/d-solo/", 1)
|
url = strings.Replace(url, "/d/", "/d-solo/", 1)
|
||||||
url = fmt.Sprintf("%s?%s", url, c.Req.URL.RawQuery)
|
url = fmt.Sprintf("%s?%s", url, c.Req.URL.RawQuery)
|
||||||
c.Redirect(url, 301)
|
c.Redirect(url, 301)
|
||||||
|
Loading…
Reference in New Issue
Block a user