mirror of
https://github.com/System-End/site.git
synced 2026-04-19 19:45:07 +00:00
ADD TLS :trollface:
This commit is contained in:
parent
4186f5d612
commit
45311bd47a
2 changed files with 24 additions and 1 deletions
23
pages/api/replit/stats.js
Normal file
23
pages/api/replit/stats.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
export default async function handler(req, res) {
|
||||
if (req.method === 'GET') {
|
||||
try {
|
||||
const url = new URL('http://takeout.hackclub.com/stats')
|
||||
const response = await fetch(url)
|
||||
|
||||
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 fetching progress:', error)
|
||||
res
|
||||
.status(500)
|
||||
.json({ error: 'Error fetching progress', message: error.message })
|
||||
}
|
||||
} else {
|
||||
// Handle any non-GET requests
|
||||
res.setHeader('Allow', ['GET'])
|
||||
res.status(405).end(`Method ${req.method} Not Allowed`)
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ const ReplitPage = () => {
|
|||
const [stats, setStats] = useState(null)
|
||||
|
||||
const fetchStats = async () => {
|
||||
const statResponse = await fetch('http://takeout.hackclub.com/stats')
|
||||
const statResponse = await fetch('/api/replit/stats')
|
||||
if (!statResponse.ok) throw new Error('Failed to fetch stats')
|
||||
const statData = await statResponse.json()
|
||||
console.info(statData)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue