Skip to content
Open
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
30 changes: 20 additions & 10 deletions orbit-app/src/components/CommentsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ function CommentsSection() {
const [comment, setComment] = useState('');
const [commentsList, setCommentsList] = useState([]);

useEffect(() => {
// Fetch all comments
axios.get(`${BASE_URL}/comments`)
.then(response => {
setCommentsList(response.data);
})
.catch(error => {
console.error('Error fetching comments:', error);
});
}, []);
() => {
// Fetch all comments
const sanitizedBaseUrl = sanitizeUrl(BASE_URL); // Ensure BASE_URL is sanitized
axios.get(`${sanitizedBaseUrl}/comments`)
.then(response => {
setCommentsList(response.data);
})
.catch(error => {
console.error('Error fetching comments:', error);
});
}

function sanitizeUrl(url) {
// Implement URL sanitization logic here
// For example, ensure the URL matches a specific pattern or whitelist
if (!/^https?:\/\//.test(url)) {
throw new Error('Invalid URL');
}
return url;
}

const handleSubmit = (e) => {
e.preventDefault();
Expand Down