diff --git a/docker-compose.yml b/docker-compose.yml index 1471a94a..cddcf800 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.8" -services: +services: web: - container_name: motherhood-beyond-bars-web + container_name: motherhood-beyond-bars-web build: context: ./web target: dev @@ -15,14 +15,14 @@ services: - /app/.next ports: - 3000:3000 - + mobile: container_name: motherhood-beyond-bars-mobile build: context: ./mobile target: dev restart: always - command: npm start + command: npm start platform: linux/amd64 environment: - NODE_ENV=development diff --git a/web/lib/encryption.ts b/web/lib/encryption.ts index d63a5f2f..cc3ac62b 100644 --- a/web/lib/encryption.ts +++ b/web/lib/encryption.ts @@ -1,11 +1,13 @@ import crypto from 'crypto'; +const key = crypto.createHash('sha256').update(String(process.env.SECRET_KEY)).digest('base64').substr(0, 32); + const encrypt = (text: string) => { const iv = crypto.randomBytes(16); const cipher = crypto.createCipheriv( 'aes-256-ctr', - process.env.SECRET_KEY!, + key!, iv ); @@ -20,7 +22,7 @@ const encrypt = (text: string) => { const decrypt = (hash: { iv: string; content: string }) => { const decipher = crypto.createDecipheriv( 'aes-256-ctr', - process.env.SECRET_KEY!, + key!, Buffer.from(hash.iv, 'hex') ); diff --git a/web/next.config.js b/web/next.config.js index dcae80b2..e55c9f98 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -5,4 +5,7 @@ module.exports = { domains: ["firebasestorage.googleapis.com"], }, output: "standalone", + // env: { + // SECRET_KEY: process.env.SECRET_KEY, + // }, }; diff --git a/web/pages/babies.tsx b/web/pages/babies.tsx index a5a55e3d..d604561f 100644 --- a/web/pages/babies.tsx +++ b/web/pages/babies.tsx @@ -182,6 +182,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => { ).toDate(); const { iv, content } = encrypt(babyDoc.id); + return { id: babyDoc.id,