Skip to content

Fix/hardcoded localhost and missing delete endpoint#46

Merged
SatyamPandey-07 merged 2 commits into
harshika53:mainfrom
OmanshiRaj:fix/hardcoded-localhost-and-missing-delete-endpoint
Jun 29, 2026
Merged

Fix/hardcoded localhost and missing delete endpoint#46
SatyamPandey-07 merged 2 commits into
harshika53:mainfrom
OmanshiRaj:fix/hardcoded-localhost-and-missing-delete-endpoint

Conversation

@OmanshiRaj

Copy link
Copy Markdown
Contributor

RecentScansSection and HistoryPage bypassed the centralised api.ts client and made raw fetch calls to a hardcoded http://localhost:5000, breaking every deployment that sets VITE_API_URL to a non-local backend. This replaces both with calls to the existing getRecentScans and getReports functions in api.ts. Additionally, HistoryPage's delete action called a POST /api/scans/delete endpoint that did not exist anywhere in the Flask backend, causing every delete to silently 404 while the UI still removed the scan from local state, making it reappear on refresh. This adds a deleteScans function to api.ts and a corresponding DELETE /api/scans/delete route in backend/app.py that removes matching documents from MongoDB by id. Verified with tsc --noEmit, npm run build, and python3 -m py_compile, all passing cleanly. Fixes #42.

handleSubmit referenced an undeclared variable trimmedUrl on line 29, causing every scan submission to throw a ReferenceError before any URL processing could happen. This adds the missing const trimmedUrl = url.trim() declaration, switches the empty-input check to use the trimmed value so whitespace-only input is also rejected, and removes a duplicate https-prefix check that was leftover dead code from the same incomplete edit. Fixes harshika53#41.
RecentScansSection and HistoryPage bypassed the centralised api.ts client and made raw fetch calls to a hardcoded http://localhost:5000, breaking every deployment that sets VITE_API_URL to a non-local backend. This replaces both with calls to the existing getRecentScans and getReports functions in api.ts. Additionally, HistoryPage's delete action called a POST /api/scans/delete endpoint that did not exist anywhere in the Flask backend, causing every delete to silently 404 while the UI still removed the scan from local state, making it reappear on refresh. This adds a deleteScans function to api.ts and a corresponding DELETE /api/scans/delete route in backend/app.py that removes matching documents from MongoDB by id. Verified with tsc --noEmit, npm run build, and python3 -m py_compile, all passing cleanly. Fixes harshika53#42.
@SatyamPandey-07
SatyamPandey-07 merged commit 5617f84 into harshika53:main Jun 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants