Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix baby page #119

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions web/lib/encryption.ts
Original file line number Diff line number Diff line change
@@ -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
);

Expand All @@ -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')
);

Expand Down
3 changes: 3 additions & 0 deletions web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ module.exports = {
domains: ["firebasestorage.googleapis.com"],
},
output: "standalone",
// env: {
// SECRET_KEY: process.env.SECRET_KEY,
// },
};
1 change: 1 addition & 0 deletions web/pages/babies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
).toDate();

const { iv, content } = encrypt(babyDoc.id);


return {
id: babyDoc.id,
Expand Down
Loading