Skip to content

Commit 244410b

Browse files
authored
Routing fixes (#88)
* feat: fixed proxy routing for backend URLs,; temp access to step 4 component via URL; * fix: docker backend ports standardized to 3000 and 3005
1 parent 2b7c4c1 commit 244410b

8 files changed

Lines changed: 41 additions & 11 deletions

File tree

apps/backend/src/auth/auth.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export class AuthController {
8686

8787
@Post('/signup')
8888
async createUser(@Body() signUpDto: SignUpDto): Promise<User> {
89+
console.log(`Signup request received for: ${signUpDto.email}`);
8990
// By default, creates a standard user
9091
try {
9192
await this.authService.signup(signUpDto);
@@ -116,6 +117,7 @@ export class AuthController {
116117

117118
@Post('/signin')
118119
async signin(@Body() signInDto: SignInDto): Promise<SignInResponseDto> {
120+
console.log(`Signin request received for: ${signInDto.email}`);
119121
try {
120122
return await this.authService.signin(signInDto);
121123
} catch (e) {

apps/backend/src/auth/auth.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ export class AuthService {
2727
private readonly clientSecret: string;
2828

2929
constructor() {
30+
console.log(
31+
`Initializing AuthService with UserPoolId: ${CognitoAuthConfig.userPoolId}, Region: ${CognitoAuthConfig.region}`,
32+
);
3033
this.providerClient = new CognitoIdentityProviderClient({
3134
region: CognitoAuthConfig.region,
3235
credentials: {
@@ -142,7 +145,9 @@ export class AuthService {
142145
});
143146

144147
try {
148+
console.log(`Calling Cognito AdminInitiateAuth for ${email}`);
145149
const response = await this.providerClient.send(signInCommand);
150+
console.log(`Cognito response received for ${email}`);
146151

147152
return {
148153
accessToken: response.AuthenticationResult.AccessToken,

apps/backend/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async function bootstrap() {
3232
.setVersion('1.0')
3333
.build();
3434
const document = SwaggerModule.createDocument(app, config);
35-
SwaggerModule.setup('api', app, document);
35+
SwaggerModule.setup('api-docs', app, document);
3636

3737
const port = process.env.PORT || 3000;
3838
await app.listen(port);

apps/frontend/src/api/apiClient.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import axios, { type AxiosInstance } from 'axios';
22

3-
const defaultBaseUrl =
4-
import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001';
3+
const defaultBaseUrl = import.meta.env.VITE_API_BASE_URL ?? '';
54

65
export type DonationCreateRequest = {
76
firstName: string;

apps/frontend/src/containers/donations/DonationForm.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import apiClient, {
33
type CreateDonationRequest,
44
} from '../../api/apiClient';
55
import React, { useState } from 'react';
6+
import { useSearchParams } from 'react-router-dom';
67
import './donations.css';
78
import {
89
DonationFormData,
@@ -21,7 +22,12 @@ export const DonationForm: React.FC<DonationFormProps> = ({
2122
onError,
2223
onAmountChange,
2324
}) => {
24-
const [currentStep, setCurrentStep] = useState<DonationStep>(1);
25+
const [searchParams] = useSearchParams();
26+
const [currentStep, setCurrentStep] = useState<DonationStep>(() => {
27+
const stepParam = searchParams.get('step');
28+
if (stepParam === '4') return 4;
29+
return 1;
30+
});
2531
const [formData, setFormData] = useState<DonationFormData>({
2632
firstName: '',
2733
lastName: '',
@@ -43,7 +49,9 @@ export const DonationForm: React.FC<DonationFormProps> = ({
4349
const [errors, setErrors] = useState<Partial<FormErrors>>({});
4450
const [isSubmitting, setIsSubmitting] = useState(false);
4551
const [submitError, setSubmitError] = useState<string | null>(null);
46-
const [receiptId, setReceiptId] = useState<string | null>(null);
52+
const [receiptId, setReceiptId] = useState<string | null>(
53+
searchParams.get('receiptId'),
54+
);
4755

4856
const clampStep = (value: number): DonationStep =>
4957
Math.max(1, Math.min(4, value)) as DonationStep;

apps/frontend/src/containers/donations/steps/Step4Receipt.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const TESTIMONIAL_SLIDES = [
3030
},
3131
];
3232

33-
export const Step4Receipt: React.FC<Step4ReceiptProps> = () => {
33+
export const Step4Receipt: React.FC<Step4ReceiptProps> = ({ receiptId }) => {
3434
const [feedback, setFeedback] = useState('');
3535

3636
const handleSpreadTheWord = () => {
@@ -66,6 +66,11 @@ export const Step4Receipt: React.FC<Step4ReceiptProps> = () => {
6666
</p>
6767
<div className="h-px w-20 bg-gray-300" />
6868
</div>
69+
{receiptId && (
70+
<p className="mt-2 text-center text-[12px] text-gray-400">
71+
Receipt ID: {receiptId}
72+
</p>
73+
)}
6974
<div className="mt-10">
7075
<label className="mb-3 block text-left">
7176
<span className="text-black text-[16px] leading-[100%] tracking-[0] font-normal [font-family:Helvetica,Arial,sans-serif]">

apps/frontend/vite.config.mts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@ export default defineConfig({
1313
host: 'localhost',
1414
proxy: {
1515
'/api': {
16-
target: 'http://localhost:3001',
16+
target: 'http://localhost:3000',
1717
changeOrigin: true,
1818
secure: false,
19+
configure: (proxy, _options) => {
20+
proxy.on('error', (err, _req, _res) => {
21+
console.log('proxy error', err);
22+
});
23+
proxy.on('proxyReq', (proxyReq, req, _res) => {
24+
console.log('Sending Request to the Target:', req.method, req.url);
25+
});
26+
proxy.on('proxyRes', (proxyRes, req, _res) => {
27+
console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
28+
});
29+
},
1930
},
2031
},
2132
fs: {

docker-compose.dev.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636
NX_DB_DATABASE: fcc_dev
3737

3838
NODE_ENV: development
39-
PORT: 3000
39+
PORT: 3005
4040

4141
# JWT and Auth (add secrets in prod)
4242
JWT_SECRET: dev-secret-change-in-prod
@@ -52,7 +52,7 @@ services:
5252
NX_AWS_SECRET_ACCESS_KEY: ${NX_AWS_SECRET_ACCESS_KEY}
5353

5454
ports:
55-
- '3000:3000'
55+
- '3005:3005'
5656
depends_on:
5757
postgres:
5858
condition: service_healthy
@@ -86,7 +86,7 @@ services:
8686
NX_DB_DATABASE: fcc_dev
8787

8888
NODE_ENV: development
89-
PORT: 3001
89+
PORT: 3000
9090

9191
# JWT and Auth (add secrets in prod)
9292
JWT_SECRET: dev-secret-change-in-prod
@@ -106,7 +106,7 @@ services:
106106
AWS_SES_SENDER_EMAIL: ${SENDER_EMAIL}
107107

108108
ports:
109-
- '3001:3001'
109+
- '3000:3000'
110110
depends_on:
111111
postgres:
112112
condition: service_healthy

0 commit comments

Comments
 (0)