Skip to content

Commit 690ef16

Browse files
committed
fix api bug
1 parent 8f394e8 commit 690ef16

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

client/src/views/dashboard/ShipmentHistory/ShipmentHistory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ShipmentHistory = () => {
1313
useEffect(() => {
1414
const fetchShipmentHistory = async () => {
1515
try {
16-
const response = await axios.get('/api/history')
16+
const response = await axios.get('/history')
1717
const data = response.data
1818
if (data.status === 'success') {
1919
setShipmentHistory(data.data)

client/src/views/driver/driverlogin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const DriverLogin = () => {
3535

3636
try {
3737
// Send login request to the backend
38-
const response = await axios.post('/api/driverlogin', {
38+
const response = await axios.post('/driverlogin', {
3939
username,
4040
password,
4141
})

client/src/views/driver/drivermanagement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DriverManagement = () => {
2121
useEffect(() => {
2222
const fetchShipments = async () => {
2323
try {
24-
const res = await fetch('https://backend-core2.axleshift.com/api/driver/shipments')
24+
const res = await fetch('https://backend-core2.axleshift.com/driver/shipments')
2525
const data = await res.json()
2626
setShipments(data)
2727
} catch (error) {

client/src/views/driver/drivertracking.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const DriverTracking = () => {
3838

3939
useEffect(() => {
4040
axios
41-
.get('/api/driver/shipments')
41+
.get('/driver/shipments')
4242
.then((response) => {
4343
setShipments(Array.isArray(response.data) ? response.data : [])
4444
})

client/src/views/pages/login/Login.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Login = () => {
3838
setErrorMessage(null)
3939

4040
try {
41-
const response = await axios.post('/api/login', { username, password })
41+
const response = await axios.post('/login', { username, password })
4242

4343
// Proceed to 2FA step
4444
setStep(2)
@@ -56,7 +56,7 @@ const Login = () => {
5656
setErrorMessage(null)
5757

5858
try {
59-
const response = await axios.post('/api/verify-2fa', { username, code })
59+
const response = await axios.post('/verify-2fa', { username, code })
6060
const { token, user } = response.data
6161

6262
sessionStorage.setItem('token', token)

client/src/views/pages/login/signup/Signup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const Signup = () => {
115115
password: formData.password,
116116
}
117117

118-
const response = await axios.post('/api/signup', userData)
118+
const response = await axios.post('/signup', userData)
119119
console.log('Signup successful:', response.data)
120120

121121
await axios.post('/api/verify-email', { email: formData.email })

server/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const transporter = nodemailer.createTransport({
239239
})
240240

241241
//Login
242-
app.post('/api/login', async (req, res) => {
242+
app.post('/login', async (req, res) => {
243243
const { username, password } = req.body
244244

245245
try {
@@ -269,7 +269,7 @@ app.post('/api/login', async (req, res) => {
269269
})
270270

271271
// Verify
272-
app.post('/api/verify-2fa', async (req, res) => {
272+
app.post('/verify-2fa', async (req, res) => {
273273
const { username, code } = req.body
274274
const entry = twoFACodes[username]
275275

@@ -296,7 +296,7 @@ app.post('/api/verify-2fa', async (req, res) => {
296296
})
297297

298298
//Signup
299-
app.post("/api/signup", async (req, res) => {
299+
app.post("/signup", async (req, res) => {
300300
try {
301301
console.log("Incoming signup request:", req.body);
302302
const { fullname, username, email, password, address } = req.body;
@@ -396,7 +396,7 @@ app.post('/api/driverlogin', async (req, res) => {
396396
});
397397

398398
//Driver get shipments
399-
app.get('/api/driver/shipments', async (req, res) => {
399+
app.get('/driver/shipments', async (req, res) => {
400400
try {
401401
const activeShipments = await TrackData.find({}, {
402402
trackingNumber: 1,
@@ -415,7 +415,7 @@ app.get('/api/driver/shipments', async (req, res) => {
415415
}
416416
})
417417
// Driver selects shipments to track
418-
app.post('/api/driver/select-shipment', async (req, res) => {
418+
app.post('/driver/select-shipment', async (req, res) => {
419419
const { trackingNumber, driverUsername } = req.body;
420420
console.log('Received for assign:', { trackingNumber, driverUsername })
421421

@@ -438,7 +438,7 @@ app.post('/api/driver/select-shipment', async (req, res) => {
438438

439439

440440
// Email
441-
app.post("/api/verify-email", async (req, res) => {
441+
app.post("/verify-email", async (req, res) => {
442442
try {
443443
const { email } = req.body;
444444
// Get user from Firebase
@@ -511,7 +511,7 @@ app.post('/resend-verification', resendEmailLimiter, async (req, res) => {
511511
});
512512

513513
// Delete
514-
app.delete('/api/track/:trackingNumber', async (req, res) => {
514+
app.delete('/track/:trackingNumber', async (req, res) => {
515515
const { trackingNumber } = req.params;
516516
try {
517517
const deletedShipment = await TrackData.findOneAndDelete({ trackingNumber });
@@ -527,7 +527,7 @@ app.delete('/api/track/:trackingNumber', async (req, res) => {
527527
});
528528

529529
// Track Shipment
530-
app.post('/api/track', async (req, res) => {
530+
app.post('/track', async (req, res) => {
531531
const { trackingNumber } = req.body;
532532

533533
try {
@@ -634,7 +634,7 @@ function getStatusMessage(status, location) {
634634
}
635635

636636

637-
app.get('/api/history', async (req, res) => {
637+
app.get('/history', async (req, res) => {
638638
try {
639639
const shippedData = await TrackData.find();
640640
if (shippedData.length > 0) {

0 commit comments

Comments
 (0)