feat(website): add GET /users/me endpoint for authenticated user lookup - #1308
Merged
Conversation
Returns the calling user's PublicUser (id + name), resolved from whichever credential the proxy injected as ?userId. Works with both session cookies and API keys since the proxy handles auth before forwarding. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without this, /api/users/me fell through to the dynamic [id].ts route which uses proxyToBackendNoAuth — no userId would be injected and the backend would return 400 (missing required param). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
From the backend perspective this is a little bit stupid ... Should this be a frontend only thing? |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a “current user” lookup endpoint that can be called via the frontend /api proxy, enabling API-key authenticated clients (e.g., a seeder) to discover their own internal user ID and then fetch user-scoped resources like collections.
Changes:
- Added a new frontend proxy route
GET /api/users/meand a client helperBackendService.getMe(). - Added a backend endpoint
GET /users/methat returns thePublicUserfor the injecteduserIdquery parameter. - Added backend controller tests covering the new endpoint (success + 404).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/pages/api/users/me.ts | Adds /api/users/me route proxying authenticated requests to the backend. |
| website/src/backendApi/backendService.ts | Adds getMe() helper for calling the new endpoint from the frontend client code. |
| backend/src/main/kotlin/org/genspectrum/dashboardsbackend/controller/UsersController.kt | Adds GET /users/me endpoint returning PublicUser. |
| backend/src/test/kotlin/org/genspectrum/dashboardsbackend/controller/UsersControllerTest.kt | Adds tests for GET /users/me success and not-found cases. |
| backend/src/test/kotlin/org/genspectrum/dashboardsbackend/controller/UsersClient.kt | Adds test client helpers to call GET /users/me. |
The backend endpoint was redundant — /users/{id} already returns the
same PublicUser shape. The frontend me.ts route now resolves the caller
from context.locals.gsUserId (set by authMiddleware for both session
cookies and API keys) and fetches /users/{id} on the backend directly.
No backend changes required.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fhennig
requested review from
fengelniederhammer
and removed request for
fengelniederhammer
July 2, 2026 12:42
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fengelniederhammer
left a comment
Contributor
There was a problem hiding this comment.
Let's change the PR title to feat(website) and add an e2e (Playwright) test for the new endpoint?
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines
+11
to
+18
| test('GET /api/users/me returns user data when authenticated', async ({ authenticatedPage }) => { | ||
| const response = await authenticatedPage.request.get('/api/users/me'); | ||
|
|
||
| expect(response.status()).toBe(200); | ||
| const body = (await response.json()) as { id: number; name: string }; | ||
| expect(typeof body.id).toBe('number'); | ||
| expect(body.name).toBe('e2e-test'); | ||
| }); |
Comment on lines
+23
to
+29
| try { | ||
| const response = await fetch(new URL(`/users/${userId}`, getBackendHost())); | ||
| return new Response(response.body, { | ||
| status: response.status, | ||
| headers: response.headers, | ||
| }); | ||
| } catch (error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
/api/users/meendpoint.I want to use this, so the seeder can - based on the given API key - find out its own user ID. It can then use this to fetch its own collections.
PR Checklist