Skip to content

Commit 0cc3605

Browse files
committed
Add environment variables for api and database
1 parent 9cc60f8 commit 0cc3605

File tree

4 files changed

+3
-6
lines changed

4 files changed

+3
-6
lines changed

new-brus-frontend/src/app/api/mongodb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type User = {
77
};
88

99
export const getUserCollection = async () => {
10-
const client: MongoClient = new MongoClient('mongodb://localhost:27017');
10+
const client: MongoClient = new MongoClient(process.env.MONGODB_URI ?? 'mongodb://localhost:27017');
1111
await client.connect();
1212
const db: Db = client.db('brus');
1313
const user_collection = db.collection<User>('users');

new-brus-frontend/src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function Home() {
2626
const [users, setUsers] = useState<User[]>([]);
2727

2828
const fetchUsers = async () => {
29-
const response = await fetch('http://localhost:3000/api/users');
29+
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL ?? 'https://localhost:3000/api'}/users`);
3030
const data = await response.json();
3131
setUsers(data);
3232
};

new-brus-frontend/src/app/theme.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

new-brus-frontend/src/components/buy-brus-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function BuyBrusModal(props: {
3434
amount,
3535
};
3636

37-
const response = await fetch('http://localhost:3000/api/buybrus', {
37+
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3000/api'}/buybrus`, {
3838
method: 'POST',
3939
headers: {
4040
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)