Browse Source

fix(rendering): minor fix for server side rendering when using non default http addr setting and non default domain setting, #6813

Torkel Ödegaard 9 năm trước cách đây
mục cha
commit
ab07667b69

+ 4 - 4
pkg/components/renderer/renderer.go

@@ -35,12 +35,12 @@ func RenderToPng(params *RenderOpts) (string, error) {
 		executable = executable + ".exe"
 		executable = executable + ".exe"
 	}
 	}
 
 
-	localAddress := "localhost"
+	localDomain := "localhost"
 	if setting.HttpAddr != setting.DEFAULT_HTTP_ADDR {
 	if setting.HttpAddr != setting.DEFAULT_HTTP_ADDR {
-		localAddress = setting.HttpAddr
+		localDomain = setting.HttpAddr
 	}
 	}
 
 
-	url := fmt.Sprintf("%s://%s:%s/%s", setting.Protocol, localAddress, setting.HttpPort, params.Path)
+	url := fmt.Sprintf("%s://%s:%s/%s", 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"))
@@ -57,7 +57,7 @@ func RenderToPng(params *RenderOpts) (string, error) {
 		"width=" + params.Width,
 		"width=" + params.Width,
 		"height=" + params.Height,
 		"height=" + params.Height,
 		"png=" + pngPath,
 		"png=" + pngPath,
-		"domain=" + setting.Domain,
+		"domain=" + localDomain,
 		"renderKey=" + renderKey,
 		"renderKey=" + renderKey,
 	}
 	}
 
 

+ 1 - 1
vendor/phantomjs/render.js

@@ -22,7 +22,7 @@
   phantom.addCookie({
   phantom.addCookie({
     'name': 'renderKey',
     'name': 'renderKey',
     'value': params.renderKey,
     'value': params.renderKey,
-    'domain': 'localhost',
+    'domain': params.domain,
   });
   });
 
 
   page.viewportSize = {
   page.viewportSize = {