mirror of
https://github.com/alangrainger/immich-public-proxy.git
synced 2024-12-28 03:41:58 +00:00
Add caching
This commit is contained in:
parent
b5ee0a1429
commit
43e038078e
5 changed files with 12 additions and 1 deletions
|
@ -2,3 +2,4 @@ IMMICH_URL=http://localhost:2283
|
|||
API_KEY="Get this from your Immich Account Settings page"
|
||||
SERVER_URL=https://shared.example.com
|
||||
SERVER_PORT=3000
|
||||
CACHE_AGE=2592000
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Immich Public Proxy
|
||||
|
||||
<p align="center" width="100%">
|
||||
<img src="public/images/immich.png" width="200" height="200">
|
||||
</p>
|
||||
|
||||
Immich is a wonderful bit of software, but since it holds all your private photos it's best to keep it fully locked down.
|
||||
This presents a problem when you want to share a photo or a gallery with someone.
|
||||
|
||||
|
@ -26,10 +30,12 @@ IMMICH_URL=http://localhost:2283
|
|||
API_KEY="Get this from your Immich Account Settings page"
|
||||
SERVER_URL=https://shared.example.com
|
||||
SERVER_PORT=3000
|
||||
CACHE_AGE=2592000
|
||||
```
|
||||
|
||||
- `IMMICH_URL` is the URL to access Immich in your local network. This is not your public URL.
|
||||
- `SERVER_URL` will be the public URL for accessing this Immich Public Proxy app.
|
||||
- `CACHE_AGE` by default, assets will be cached for 30 days. Set this to 0 to disable caching.
|
||||
|
||||
3. Start the docker container:
|
||||
|
||||
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
File diff suppressed because one or more lines are too long
BIN
public/images/immich.png
Normal file
BIN
public/images/immich.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
|
@ -16,6 +16,7 @@ const getSize = (req: Request) => {
|
|||
}
|
||||
|
||||
app.get('/share/:key', async (req, res) => {
|
||||
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE)
|
||||
if (!immich.isKey(req.params.key)) {
|
||||
res.status(404).send()
|
||||
} else {
|
||||
|
@ -41,6 +42,7 @@ app.get('/share/:key', async (req, res) => {
|
|||
|
||||
// Output the buffer data for an photo or video
|
||||
app.get('/:type(photo|video)/:key/:id', async (req, res) => {
|
||||
res.set('Cache-Control', 'public, max-age=' + process.env.CACHE_AGE)
|
||||
// Check for valid key and ID
|
||||
if (immich.isKey(req.params.key) && immich.isId(req.params.id)) {
|
||||
// Check if the key is a valid share link
|
||||
|
|
Loading…
Reference in a new issue