Skip to content

feat: connect Next.js frontend to ASP.NET Core backend with CORS and OAuth#28

Merged
naheel0 merged 2 commits intomainfrom
copilot/connect-frontend-backend
Mar 17, 2026
Merged

feat: connect Next.js frontend to ASP.NET Core backend with CORS and OAuth#28
naheel0 merged 2 commits intomainfrom
copilot/connect-frontend-backend

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

Wires up the GitQuest frontend and backend end-to-end: CORS policy, GitHub OAuth callback, HttpOnly JWT cookie storage, and a typed fetch wrapper for all API endpoints.

Backend

  • CORS — reads allowed origins from AllowedOrigins[] in config (env-var overridable via AllowedOrigins__0=https://...); adds AllowCredentials(); throws at startup in production if origins are still set to localhost
  • Auth route aliasAuthController now also handles POST /api/auth/github alongside the existing github-login route
// appsettings.json
"AllowedOrigins": ["http://localhost:3000"]

Frontend

  • lib/api.ts — typed ApiResponse<T> fetch wrapper; no thrown exceptions; covers all five endpoints (loginWithGitHub, discoverIssues, claimIssue, getMyQuests, submitQuest)
  • lib/auth.ts — JWT stored in HttpOnly cookie (server-side only); non-sensitive user info in a separate readable cookie for client components; helpers for set/clear/read
  • app/api/auth/callback/github/route.ts — OAuth code → backend exchange → HttpOnly cookie → redirect to /discover; error messages are sanitized before surfacing to the user
  • app/api/auth/logout/route.ts — clears both cookies server-side
  • next.config.mjs — exposes NEXT_PUBLIC_API_BASE_URL (fallback: http://localhost:5198)

Environment variable docs

  • frontend/.env.exampleNEXT_PUBLIC_API_BASE_URL, NEXT_PUBLIC_GITHUB_CLIENT_ID
  • Backend/.env.example — connection string, JWT settings, GitHub OAuth, CORS origins using ASP.NET Core's __ separator syntax

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fonts.googleapis.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/GitQuest/GitQuest/frontend/node_modules/.bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…auth.ts, env examples

Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com>
Copilot AI changed the title [WIP] Add connection setup between GitQuest frontend and backend Connect Next.js frontend to ASP.NET Core backend: CORS, OAuth, typed API client Mar 17, 2026
Copilot AI requested a review from jaseel0 March 17, 2026 13:54
@jaseel0 jaseel0 marked this pull request as ready for review March 17, 2026 14:08
@github-actions github-actions bot added security Security-related changes or issues configuration Configuration file changes labels Mar 17, 2026
@naheel0 naheel0 changed the title Connect Next.js frontend to ASP.NET Core backend: CORS, OAuth, typed API client feat: connect Next.js frontend to ASP.NET Core backend with CORS and OAuth Mar 17, 2026
@naheel0 naheel0 merged commit 912b279 into main Mar 17, 2026
10 of 13 checks passed
@naheel0 naheel0 deleted the copilot/connect-frontend-backend branch March 17, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Configuration file changes security Security-related changes or issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants