Don't proxy replit stats requests through a nextjs api route

This commit is contained in:
Malted 2024-09-05 16:39:04 -04:00
parent bf1a6aab2a
commit cac4ed883a
No known key found for this signature in database
3 changed files with 1 additions and 26 deletions

View file

@ -95,7 +95,6 @@
"remark": "^15.0.1",
"remark-gfm": "^3.0.1",
"remark-html": "^16.0.1",
"socket.io": "^4.7.5",
"styled-components": "^6.1.8",
"swr": "^2.2.4",
"theme-ui": "^0.14",

View file

@ -1,24 +0,0 @@
export default async function handler(req, res) {
if (req.method === 'GET') {
try {
const response = await fetch('http://takeout.hackclub.com/stats')
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
res.status(200).json(data)
} catch (error) {
console.error('Error processing signup:', error)
res
.status(500)
.json({ message: 'Error processing signup', error: error.message })
}
} else {
// Handle any non-POST requests
res.setHeader('Allow', ['POST'])
res.status(405).end(`Method ${req.method} Not Allowed`)
}
}

View file

@ -16,7 +16,7 @@ const ReplitPage = () => {
const [stats, setStats] = useState(null)
const fetchStats = async () => {
const statResponse = await fetch('/api/replit/stats')
const statResponse = await fetch('http://takeout.hackclub.com/stats')
if (!statResponse.ok) throw new Error('Failed to fetch stats')
const statData = await statResponse.json()
console.info(statData)