From b26578a409a4ddc07ea81d4552be700e8a6cd196 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Mon, 25 Apr 2022 17:58:03 +0200 Subject: [PATCH] fixed expiration date --- .env.example | 4 +--- .setup/services/api.service.ts | 2 +- .setup/services/aw.service.ts | 2 +- package.json | 2 +- src/pages/upload.tsx | 2 +- src/utils/appwriteServer.util.ts | 7 ++++++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 6ea1638..a9f88cc 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,4 @@ APPWRITE_FUNCTION_API_KEY= -# IMPORTANT If you're running the website inside docker and your Appwrite instance runs on localhost host, -# use host.docker.internal instead of localhost -NEXT_PUBLIC_APPWRITE_HOST=http://host.docker.internal/v1 +NEXT_PUBLIC_APPWRITE_HOST=http://localhost:86/v1 # Must be the same as in the _APP_STORAGE_LIMIT in the Appwrite env file NEXT_PUBLIC_MAX_FILE_SIZE=300000000 \ No newline at end of file diff --git a/.setup/services/api.service.ts b/.setup/services/api.service.ts index 23557f5..5a87bb4 100644 --- a/.setup/services/api.service.ts +++ b/.setup/services/api.service.ts @@ -2,7 +2,7 @@ import axios from "axios"; const api = () => axios.create({ - baseURL: process.env["NEXT_PUBLIC_APPWRITE_HOST"], + baseURL: process.env["APPWRITE_HOST"], headers: { cookie: `a_session_console=${process.env["APPWRITE_USER_TOKEN"]}`, }, diff --git a/.setup/services/aw.service.ts b/.setup/services/aw.service.ts index 2418aff..1e053d2 100644 --- a/.setup/services/aw.service.ts +++ b/.setup/services/aw.service.ts @@ -3,7 +3,7 @@ const aw = () => { let client = new sdk.Client(); client - .setEndpoint(process.env["NEXT_PUBLIC_APPWRITE_HOST"]) + .setEndpoint(process.env["APPWRITE_HOST"]) .setProject("pingvin-share") .setKey(process.env["APPWRITE_API_KEY"]) .setSelfSigned(); diff --git a/package.json b/package.json index a300ae0..02ee096 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "start": "next start", "lint": "next lint", "init:appwrite": "cd .setup && npm install && npx ts-node index.ts", - "deploy": "docker buildx build -t git.elias.li/stonith404/pingvin-share:latest --platform linux/amd64,linux/arm64 --push ." + "deploy": "docker build -t git.elias.li/stonith404/pingvin-share:latest . && docker push git.elias.li/stonith404/pingvin-share:latest" }, "dependencies": { "@mantine/core": "^4.1.3", diff --git a/src/pages/upload.tsx b/src/pages/upload.tsx index ad9c50b..8d736a8 100644 --- a/src/pages/upload.tsx +++ b/src/pages/upload.tsx @@ -52,7 +52,7 @@ const Upload = () => { showCompletedUploadModal( modals, `${window.location.origin}/share/${bucketId}`, - new Date(Date.now()).toLocaleString() + new Date(Date.now() + expiration * 60 * 1000).toLocaleString() ); } }, diff --git a/src/utils/appwriteServer.util.ts b/src/utils/appwriteServer.util.ts index b6916d6..bd68edf 100644 --- a/src/utils/appwriteServer.util.ts +++ b/src/utils/appwriteServer.util.ts @@ -4,7 +4,12 @@ import sdk from "node-appwrite"; const client = new sdk.Client(); client - .setEndpoint(process.env["NEXT_PUBLIC_APPWRITE_HOST"] as string) + .setEndpoint( + (process.env["NEXT_PUBLIC_APPWRITE_HOST"] as string).replace( + "localhost", + "host.docker.internal" + ) + ) .setProject("pingvin-share") .setKey(process.env["APPWRITE_FUNCTION_API_KEY"] as string);