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 api urls #38

Merged
merged 4 commits into from
Jun 20, 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
5 changes: 4 additions & 1 deletion .envexample
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ FUSIONAUTH_POSTGRES_USER: fusionauth
FUSIONAUTH_POSTGRES_PASSWORD: password
FUSIONAUTH_API_KEY: 00c24029-e66a-43f2-9000-544e90e8d46e
FUSIONAUTH_URL: http://fusionauth:9011
FUSIONAUTH_APPLICATION_ID: 23e4b229-1219-42e5-aed6-f9b6f1eedef8
FUSIONAUTH_APPLICATION_ID: 23e4b229-1219-42e5-aed6-f9b6f1eedef8

# Frontend
API_BASE_URL=http://proxy/cpf/api
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ Kellton Europe CPF app is an innovative web-based platform – a seamless soluti
# Installation
Instructions on how to install and set up the project.

1. Copy variables to `.env` files.
```
cp .envexample .env
```
2. Build and run the project
```
docker compose build
docker compose up
```
or just
```
docker compose up --build
```
3. Open http://0.0.0.0:8080/ with your browser to see the result.

# Usage
Instructions on how to use the project.

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ services:
- ./frontend/public:/code/public
ports:
- '3000:3000'
env_file:
- .env

api-server:
image: cpf/backend-image
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const baseUrl = process.env.API_BASE_URL;

export const API_URLS = {
library: {
ladders: `${baseUrl}/library/ladders`,
buckets: `${baseUrl}/library/buckets`,
},
};
3 changes: 2 additions & 1 deletion frontend/src/app/(app)/library/[ladder]/[bucket]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { mapKeysToCamelCase } from '@app/utils';
import { API_URLS } from '@app/api';

async function getBucketDetails(slug: string) {
const response = await fetch(`https://proxy/cpf/api/library/buckets/${slug}`);
const response = await fetch(`${API_URLS.library.buckets}/${slug}`);

if (!response.ok) {
throw new Error('Failed to fetch bucket details');
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/(app)/library/[ladder]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Breadcrumbs } from '@app/components/modules/Breadcrumbs';
import { LibraryDetailed } from '@app/components/modules/LibraryDetailed';
import { mapKeysToCamelCase } from '@app/utils';
import { API_URLS } from '@app/api';

async function getLadderDetails(slug: string) {
const response = await fetch(`https://proxy/cpf/api/library/ladders/${slug}`);
const response = await fetch(`${API_URLS.library.ladders}/${slug}`);

if (!response.ok) {
throw new Error('Failed to fetch ladder details');
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/(app)/library/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { mapKeysToCamelCase } from '@app/utils';
import { LadderCard, LadderCardInterface } from '@app/components/common/LadderCard';
import { API_URLS } from '@app/api';

async function getLadders() {
const response = await fetch('https://proxy/cpf/api/library/ladders');
const response = await fetch(API_URLS.library.ladders);

if (!response.ok) {
throw new Error('Failed to fetch ladders');
Expand Down