#112 Improve og:image base URL function
This commit is contained in:
@@ -140,16 +140,17 @@ There are some additional configuration options you can change, for example the
|
|||||||
|
|
||||||
### Immich Public Proxy options
|
### Immich Public Proxy options
|
||||||
|
|
||||||
| Option | Type | Description |
|
| Option | Type | Description |
|
||||||
|-------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|-------------------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
| `publicBaseUrl` | `string` | Set this to be the base public URL of your IPP instance. This is used for generating the `og:image` URL. If you want to use multiple public URLs, you can instead set this value to `null` and send a `publicBaseUrl` header on the request from your reverse proxy to IPP. |
|
||||||
| `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
|
| `responseHeaders` | `object` | Change the headers sent with your web responses. By default there is `cache-control` and CORS added. |
|
||||||
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
|
| `singleImageGallery` | `bool` | By default a link to a single image will directly open the image file. Set to `true` if you want to show a gallery page instead for a single item. |
|
||||||
| `showGalleryTitle` | `bool` | Show a title on the gallery page. |
|
| `downloadOriginalPhoto` | `bool` | Set to `false` if you only want people to be able to download the 'preview' quality photo, rather than your original photo. |
|
||||||
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
|
| `showGalleryTitle` | `bool` | Show a title on the gallery page. |
|
||||||
| `showHomePage` | `bool` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
| `allowDownloadAll` | `int` | Allow visitors to download all files as a zip.<br>`0` disable downloads<br>`1` follow Immich setting per share ([example](https://github.com/user-attachments/assets/79ea8c08-71ce-42ab-b025-10aec384938a))<br>`2` always allowed |
|
||||||
| `showMetadata` | `object` | See the [Metadata](#metadata) section below. |
|
| `showHomePage` | `bool` | Set to `false` to remove the IPP shield page at `/` and at `/share` |
|
||||||
| `customInvalidResponse` | various | Send a custom response instead of the default 404 - see [Custom responses](docs/custom-responses.md) for more details. |
|
| `showMetadata` | `object` | See the [Metadata](#metadata) section below. |
|
||||||
|
| `customInvalidResponse` | various | Send a custom response instead of the default 404 - see [Custom responses](docs/custom-responses.md) for more details. |
|
||||||
|
|
||||||
For example, to disable the home page at `/` and at `/share` you need to change `showHomePage` to `false`:
|
For example, to disable the home page at `/` and at `/share` you need to change `showHomePage` to `false`:
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ipp": {
|
"ipp": {
|
||||||
|
"publicBaseUrl": "https://your-proxy-url.com",
|
||||||
"responseHeaders": {
|
"responseHeaders": {
|
||||||
"Cache-Control": "public, max-age=2592000",
|
"Cache-Control": "public, max-age=2592000",
|
||||||
"Access-Control-Allow-Origin": "*"
|
"Access-Control-Allow-Origin": "*"
|
||||||
|
|||||||
Generated
+9
-9
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.11.5",
|
"version": "1.12.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.11.5",
|
"version": "1.12.0",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
@@ -1261,14 +1261,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cookie-session": {
|
"node_modules/cookie-session": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/cookie-session/-/cookie-session-2.1.1.tgz",
|
||||||
"integrity": "sha512-u73BDmR8QLGcs+Lprs0cfbcAPKl2HnPcjpwRXT41sEV4DRJ2+W0vJEEZkG31ofkx+HZflA70siRIjiTdIodmOQ==",
|
"integrity": "sha512-ji3kym/XZaFVew1+tIZk5ZLp9Z/fLv9rK1aZmpug0FsgE7Cu3ZDrUdRo7FT9vFjMYfNimrrUHJzywDwT7XEFlg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cookies": "0.9.1",
|
"cookies": "0.9.1",
|
||||||
"debug": "3.2.7",
|
"debug": "3.2.7",
|
||||||
"on-headers": "~1.0.2",
|
"on-headers": "~1.1.0",
|
||||||
"safe-buffer": "5.2.1"
|
"safe-buffer": "5.2.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -3927,9 +3927,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/on-headers": {
|
"node_modules/on-headers": {
|
||||||
"version": "1.0.2",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
|
||||||
"integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==",
|
"integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.8"
|
"node": ">= 0.8"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "1.11.5",
|
"version": "1.12.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "ts-node src/index.ts",
|
"dev": "ts-node src/index.ts",
|
||||||
"build": "npx tsc",
|
"build": "npx tsc",
|
||||||
|
|||||||
+5
-7
@@ -89,12 +89,9 @@ class Render {
|
|||||||
async gallery (res: Response, share: SharedLink, openItem?: number) {
|
async gallery (res: Response, share: SharedLink, openItem?: number) {
|
||||||
const items = []
|
const items = []
|
||||||
|
|
||||||
// Originally I had the base URL as a config option in .env.
|
// publicBaseUrl is used for the og:image, which requires a fully qualified URL.
|
||||||
// The issue with that is people who may be wanting to route in via multiple
|
// You can specify this in your config.json file, or send it dynamically as a `host` header
|
||||||
// public URLs. So instead we generate the base URL from the incoming request data.
|
const publicBaseUrl = getConfigOption('ipp.publicBaseUrl', null) || res.req.headers.publicBaseUrl || ''
|
||||||
// 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
|
|
||||||
|
|
||||||
for (const asset of share.assets) {
|
for (const asset of share.assets) {
|
||||||
let video, downloadUrl
|
let video, downloadUrl
|
||||||
@@ -118,7 +115,7 @@ class Render {
|
|||||||
downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original)
|
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 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, ''') : ''
|
const description = getConfigOption('ipp.showMetadata.description', false) && typeof asset?.exifInfo?.description === 'string' ? asset.exifInfo.description.replace(/'/g, ''') : ''
|
||||||
|
|
||||||
@@ -141,6 +138,7 @@ class Render {
|
|||||||
items,
|
items,
|
||||||
openItem,
|
openItem,
|
||||||
title: this.title(share),
|
title: this.title(share),
|
||||||
|
publicBaseUrl,
|
||||||
path: '/share/' + share.key,
|
path: '/share/' + share.key,
|
||||||
showDownload: canDownload(share),
|
showDownload: canDownload(share),
|
||||||
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
showTitle: getConfigOption('ipp.showGalleryTitle', false),
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// Add an og-image using the first image's thumbnail
|
// Add an og-image using the first image's thumbnail
|
||||||
if (items?.[0]?.thumbnailUrl) {
|
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 rel="icon" href="/share/static/favicon.ico" type="image/x-icon">
|
||||||
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
|
<link type="text/css" rel="stylesheet" href="/share/static/style.css"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user