#112 Improve og:image base URL function
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"ipp": {
|
||||
"publicBaseUrl": "https://your-proxy-url.com",
|
||||
"responseHeaders": {
|
||||
"Cache-Control": "public, max-age=2592000",
|
||||
"Access-Control-Allow-Origin": "*"
|
||||
|
||||
Generated
+9
-9
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.11.5",
|
||||
"version": "1.12.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.11.5",
|
||||
"version": "1.12.0",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"archiver": "^7.0.1",
|
||||
@@ -1261,14 +1261,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-session": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-2.1.0.tgz",
|
||||
"integrity": "sha512-u73BDmR8QLGcs+Lprs0cfbcAPKl2HnPcjpwRXT41sEV4DRJ2+W0vJEEZkG31ofkx+HZflA70siRIjiTdIodmOQ==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-2.1.1.tgz",
|
||||
"integrity": "sha512-ji3kym/XZaFVew1+tIZk5ZLp9Z/fLv9rK1aZmpug0FsgE7Cu3ZDrUdRo7FT9vFjMYfNimrrUHJzywDwT7XEFlg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookies": "0.9.1",
|
||||
"debug": "3.2.7",
|
||||
"on-headers": "~1.0.2",
|
||||
"on-headers": "~1.1.0",
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
@@ -3927,9 +3927,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/on-headers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
|
||||
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
|
||||
"integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "immich-public-proxy",
|
||||
"version": "1.11.5",
|
||||
"version": "1.12.0",
|
||||
"scripts": {
|
||||
"dev": "ts-node src/index.ts",
|
||||
"build": "npx tsc",
|
||||
|
||||
+5
-7
@@ -89,12 +89,9 @@ class Render {
|
||||
async gallery (res: Response, share: SharedLink, openItem?: number) {
|
||||
const items = []
|
||||
|
||||
// Originally I had the base URL as a config option in .env.
|
||||
// The issue with that is people who may be wanting to route in via multiple
|
||||
// public URLs. So instead we generate the base URL from the incoming request data.
|
||||
// This may cause issues with some reverse proxies, in which case just make sure
|
||||
// that you're sending the correct `host` header to IPP.
|
||||
const baseUrl = res.req.protocol + '://' + res.req.headers.host
|
||||
// publicBaseUrl is used for the og:image, which requires a fully qualified URL.
|
||||
// You can specify this in your config.json file, or send it dynamically as a `host` header
|
||||
const publicBaseUrl = getConfigOption('ipp.publicBaseUrl', null) || res.req.headers.publicBaseUrl || ''
|
||||
|
||||
for (const asset of share.assets) {
|
||||
let video, downloadUrl
|
||||
@@ -118,7 +115,7 @@ class Render {
|
||||
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original)
|
||||
}
|
||||
|
||||
const thumbnailUrl = baseUrl + immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
|
||||
const thumbnailUrl = immich.photoUrl(share.key, asset.id, ImageSize.thumbnail)
|
||||
const previewUrl = immich.photoUrl(share.key, asset.id, immich.getPreviewImageSize(asset))
|
||||
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, ''') : ''
|
||||
|
||||
@@ -141,6 +138,7 @@ class Render {
|
||||
items,
|
||||
openItem,
|
||||
title: this.title(share),
|
||||
publicBaseUrl,
|
||||
path: '/share/' + share.key,
|
||||
showDownload: canDownload(share),
|
||||
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// Add an og-image using the first image's thumbnail
|
||||
if (items?.[0]?.thumbnailUrl) {
|
||||
%>
|
||||
<meta property="og:image" content="<%- items[0].thumbnailUrl %>"/>
|
||||
<meta property="og:image" content="<%- publicBaseUrl %><%- items[0].thumbnailUrl %>"/>
|
||||
<% } %>
|
||||
<link rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
|
||||
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
|
||||
|
||||
Reference in New Issue
Block a user