Skip to content

Commit

Permalink
Merge pull request #1073 from geoadmin/bugfix-PB-1017-unproxify-print…
Browse files Browse the repository at this point in the history
…-jobs

PB-1017: un-proxy external graphics in print specs
  • Loading branch information
ltkum committed Sep 23, 2024
2 parents 4da8a85 + cdb5a55 commit d0f0931
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/api/file-proxy.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ export function proxifyUrl(url) {
}
return `${getServiceProxyBaseUrl()}${fileAsPath}`
}

export function unProxifyUrl(proxified_url) {
if (
(typeof proxified_url === 'string' || proxified_url instanceof String) &&
proxified_url.startsWith(getServiceProxyBaseUrl())
) {
let url = proxified_url.replace(getServiceProxyBaseUrl(), '')
return `${url.split('/')[0]}://${decodeURIComponent(url.split('/')[1])}`
}

return proxified_url
}
4 changes: 4 additions & 0 deletions src/api/print.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import axios from 'axios'
import { Circle } from 'ol/style'

import { unProxifyUrl } from '@/api/file-proxy.api'
import {
getApi3BaseUrl,
getViewerDedicatedServicesBaseUrl,
Expand Down Expand Up @@ -116,6 +117,9 @@ class GeoAdminCustomizer extends BaseCustomizer {
if (symbolizer.externalGraphic) {
size = image.getSize()
anchor = image.getAnchor()
// service print can't handle a proxied url, so we ensure we're
// giving the original url for the print job.
symbolizer.externalGraphic = unProxifyUrl(symbolizer.externalGraphic)
} else if (image instanceof Circle) {
const radius = image.getRadius()
const width = adjustWidth(2 * radius, this.printResolution)
Expand Down

0 comments on commit d0f0931

Please sign in to comment.