Skip to content

Commit

Permalink
Add cors header
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAProton committed Oct 24, 2024
1 parent 25866c7 commit 8cdf92e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/MCQ/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const MCQ = ({
onClick={() => onLock(ansStore.value.ans)}
disabled={locked || !ansStore.value?.ans?.length}
>
Lock in
{locked ? "Locked in" : "Lock in"}
</button>
</div>
);
Expand All @@ -105,7 +105,7 @@ const MCQ = ({
function HintModal({ hint, onClose }) {
return (
<div
className="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center w-full"
className="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center w-full z-50"
onClick={onClose}
>
<div
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/MCQ/option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ const Option = ({
? `bg-[#ff9999] text-[#4a2b2b] shadow-md shadow-[#ffd0d0] ${
locked ? "opacity-60 cursor-not-allowed" : "cursor-pointer"
}`
: `bg-[#e7e7d8] text-[#2a2a2a] shadow-md shadow-[#ff9999] ${
locked ? "opacity-60 cursor-not-allowed" : "cursor-pointer"
}`
: `bg-[#e7e7d8] text-[#2a2a2a] shadow-md shadow-[#ff9999] hover:shadow-lg"
${locked ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`
} p-3 m-2 cursor-pointer transition-all duration-200 options-font text-lg`}
onClick={handleClick}
>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/Leaderboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ function LeaderboardEntry(props: { username: string; time: number }) {
<div class="flex flex-row bg-[#2a2a2a] p-2 m-1 shadow-md w-[80vh]">
<p>{props.username}</p>
<div class="flex-grow"></div>
<p>{props.time}ms</p>
<p>{formatMstoSec(props.time)}</p>
</div>
);
}

function formatMstoSec(ms: number) {
// show upto 1 decimal place 1.1s
return (ms / 1000).toFixed(1) + "s";
}

export default Leaderboard;
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func main() {
e.Use(middleware.Logger())
e.Use(middleware.Recover())

e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"http://localhost:5173", "https://carp.iiitk.in", "https://iiitk-carp.pages.dev"},
AllowMethods: []string{echo.GET, echo.PUT, echo.POST, echo.DELETE},
}))

e.GET("/", func(c echo.Context) error {
return c.HTML(200, "<p>You're not supposed to be here</p><script>console.log(\"Hi there :) We're looking for curious people like you join the Cyber Security Club at IIITK https://discord.gg/pVShHhrfX4 \")</script>")
})
Expand Down

0 comments on commit 8cdf92e

Please sign in to comment.