Skip to content

chore(deps): #64 drop unused @vercel/remote-nx#70

Closed
fray-cloud wants to merge 4 commits into
devfrom
deploy/64-drop-remote-nx
Closed

chore(deps): #64 drop unused @vercel/remote-nx#70
fray-cloud wants to merge 4 commits into
devfrom
deploy/64-drop-remote-nx

Conversation

@fray-cloud

@fray-cloud fray-cloud commented Apr 13, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on #69. @vercel/remote-nx wires Nx Remote Cache into a Vercel-hosted endpoint via tasksRunnerOptions in nx.json. This repo has never had any tasksRunnerOptions wired to it (we use the standard Nx Cloud runner via nxCloudAccessToken), so the dep is dead weight.

Closes #64.

Test plan

  • grep '@vercel/remote-nx' apps libs → zero source references
  • npx nx affected -t lint test build --exclude web-e2e green (10/10 cache hits)

🤖 Generated with Claude Code

Summary by Sourcery

Route public-data-portal traffic through a Next.js API proxy using a server-only key, migrate clients to the v2 abandonment API, and drop unused Vercel/Nx integration config and dependency.

New Features:

  • Add a Next.js route handler that proxies data.go.kr abandonment API requests and injects the server-side DATA_GO_KR_SERVICE_KEY.

Bug Fixes:

  • Ensure the public-data-portal API key is no longer exposed to the browser by moving key injection to a server-side proxy.

Enhancements:

  • Update web client requests and shared response types to use the v2 abandonment API paths and support multiple image fields.
  • Adjust the animal search card to consume the new primary image field from the v2 API.

Build:

  • Remove the unused @vercel/remote-nx dependency from the project.

Deployment:

  • Delete legacy Vercel configuration that is no longer needed with the new Next.js route handler proxy.

Root vercel.json was a Vite SPA rewrite (\`/(.*) → /index.html\`) that
would break Next.js deploys by routing every path into a nonexistent
index.html. The Next App Router handles routing itself — no rewrite
needed at the Vercel layer.

Per the Vercel monorepo guide and the roadmap, web and api will each
become their own Vercel project with Root Directory apps/web and
apps/api respectively. Root-level vercel.json would apply to both and
cannot express per-app config coherently, so it stays removed.

- nx affected -t lint test build --exclude web-e2e green
- nx.json sharedGlobals previously referenced .circleci and
  .github/workflows/ci.yml, not vercel.json — no cache invalidation
  to worry about

Refs #62
Closes the server-only half of #3 by routing every public-data-portal
call through a Next Route Handler that reads the key from
process.env.DATA_GO_KR_SERVICE_KEY (no NEXT_PUBLIC_ prefix). The
browser bundle no longer carries the key.

apps/web/app/api/data-go-kr/[...path]/route.ts (new):
- Catch-all GET handler that mirrors the upstream
  http://apis.data.go.kr/1543061/abandonmentPublicSrvc/<path> structure
- Reads search params from the incoming request, injects serviceKey
  and _type=json server-side, then forwards via fetch
- Passes through status/content-type, returns 500 if the env var is
  missing, 502 if the upstream fetch throws

apps/web/src/new-api/service.ts:
- baseURL switched to '/api/data-go-kr' (relative path, no host)
- Drops the serviceKey query param entirely — the proxy handles it
- Drops the import.meta / process.env env-check code
- Same export surface (getAPI, serviceAPI) so all 5 callers under
  new-api/{animalInfo,kind,sigungu,shelter,sido} keep working
  unchanged

apps/web/.env.example:
- NEXT_PUBLIC_DATA_GO_KR_SERVICE_KEY → DATA_GO_KR_SERVICE_KEY
- Comment updated: server-only, read by the Route Handler

Build output:
  ○ /
  ○ /_not-found
  ƒ /api/data-go-kr/[...path]   ← new dynamic route
  ○ /like
  ○ /search

- nx affected -t lint test build --exclude web-e2e green

Refs #63
The public-data-portal endpoint moved to v2 with a renamed base path
and per-resource _v2 suffixes. Update the proxy and the consumers in
the same PR so the Route Handler delivered in the previous commit
keeps working end-to-end.

Route Handler upstream URL:
- http://apis.data.go.kr/1543061/abandonmentPublicSrvc
+ https://apis.data.go.kr/1543061/abandonmentPublicService_v2
(now also HTTPS, matching the v2 spec at data.go.kr/data/15098931)

new-api path constants (all five callers):
- /abandonmentPublic → /abandonmentPublic_v2
- /sido → /sido_v2
- /sigungu → /sigungu_v2
- /kind → /kind_v2
- /shelter → /shelter_v2

shared-types AnimalInfo:
- popfile (single Image URL) → popfile1 (required) plus optional
  popfile2..popfile8. The v2 schema returns up to 8 image URLs per
  rescue notice; we only render the first today, but the optional
  fields are typed for the gallery work in #18 e2e / future ports.

apps/web AnimalCard.tsx:
- item.popfile → item.popfile1

- nx affected -t lint test build --exclude web-e2e green

Refs #63
@vercel/remote-nx wires Nx Remote Cache into a Vercel-hosted endpoint
via tasksRunnerOptions in nx.json. Our nx.json has never had any
tasksRunnerOptions wired to it (we now use the standard Nx Cloud
runner via nxCloudAccessToken), so the dependency was dead weight.

- grep '@vercel/remote-nx' apps libs → zero source references
- nx affected -t lint test build --exclude web-e2e green (10/10 cache)

Refs #64
@vercel

vercel Bot commented Apr 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
animal-project Error Error Apr 13, 2026 1:34pm

@sourcery-ai

sourcery-ai Bot commented Apr 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates the web app to use the official v2 public-data-portal API via a Next.js route handler proxy (hiding the API key from the browser), updates shared response types and API clients accordingly, adjusts image field usage, and drops the unused @vercel/remote-nx dependency and related Vercel config.

Sequence diagram for proxied v2 public-data-portal requests

sequenceDiagram
  actor Browser
  participant AnimalSearchUI
  participant NewAPIClient as NewAPI_client_functions
  participant NextRoute as Next_data_go_kr_route
  participant PublicAPI as Public_data_portal_v2

  Browser->>AnimalSearchUI: Search/Filter interaction
  AnimalSearchUI->>NewAPIClient: getAnimalInfo(props)
  NewAPIClient->>NextRoute: GET /api/data-go-kr/abandonmentPublic_v2?query
  NextRoute->>NextRoute: Read DATA_GO_KR_SERVICE_KEY
  NextRoute->>PublicAPI: GET /abandonmentPublicService_v2/abandonmentPublic_v2?query&serviceKey&_type=json
  PublicAPI-->>NextRoute: JSON response
  NextRoute-->>NewAPIClient: Proxied JSON response
  NewAPIClient-->>AnimalSearchUI: APIResponse<AnimalInfo>
  AnimalSearchUI-->>Browser: Render AnimalCard with item.popfile1
Loading

ER diagram for updated APIResponse image fields

erDiagram
  APIResponse {
    string response_header_resultCode
    string response_header_resultMsg
    number response_body_items_totalCount
  }

  APIItem {
    string noticeNo
    string noticeSdt
    string noticeEdt
    string popfile1
    string popfile2
    string popfile3
    string popfile4
    string popfile5
    string popfile6
    string popfile7
    string popfile8
    string processState
    string sexCd
    string neuterYn
  }

  APIResponse ||--o{ APIItem : contains_items
Loading

Class diagram for updated web API client and route handler

classDiagram
  class ServiceAPIClient {
    - string baseURL
    + getAPI(props, path) Promise
  }

  class AnimalInfoAPI {
    + getAnimalInfo(props) Promise
  }

  class KindAPI {
    + getKind(props) Promise
  }

  class ShelterAPI {
    + getShelter(props) Promise
  }

  class SidoAPI {
    + getSido(props) Promise
  }

  class SigunguAPI {
    + getSigungu(props) Promise
  }

  class DataGoKrRouteHandler {
    - string UPSTREAM_BASE
    + GET(request, context) Promise
  }

  ServiceAPIClient <|.. AnimalInfoAPI
  ServiceAPIClient <|.. KindAPI
  ServiceAPIClient <|.. ShelterAPI
  ServiceAPIClient <|.. SidoAPI
  ServiceAPIClient <|.. SigunguAPI

  DataGoKrRouteHandler --> ServiceAPIClient : serves_requests_for
  AnimalInfoAPI --> DataGoKrRouteHandler : calls
  KindAPI --> DataGoKrRouteHandler : calls
  ShelterAPI --> DataGoKrRouteHandler : calls
  SidoAPI --> DataGoKrRouteHandler : calls
  SigunguAPI --> DataGoKrRouteHandler : calls
Loading

File-Level Changes

Change Details Files
Route data-go-kr traffic through a Next.js Route Handler proxy and stop exposing the API key to the browser.
  • Replace direct public-data-portal baseURL with a relative /api/data-go-kr baseURL used by the browser-facing axios client.
  • Remove client-side use of NEXT_PUBLIC_DATA_GO_KR_SERVICE_KEY and related logging from the web app service module.
  • Add a Next.js app router route handler that proxies to the upstream abandonmentPublicService_v2 API, injects the server-only DATA_GO_KR_SERVICE_KEY and _type=json into query params, and streams back the upstream response with appropriate headers and error handling.
apps/web/src/new-api/service.ts
apps/web/app/api/data-go-kr/[...path]/route.ts
Update domain types and API clients to align with the v2 abandonment service and its image fields.
  • Change API endpoints used by animal, kind, shelter, sido, and sigungu client functions to their *_v2 variants.
  • Expand the API response type to model multiple image URL fields popfile1..popfile8 with appropriate optionality.
  • Update the AnimalCard component to use popfile1 instead of the legacy popfile field for the primary image.
libs/shared-types/src/lib/responseAPI.ts
apps/web/src/new-api/animalInfo/index.ts
apps/web/src/new-api/kind/index.ts
apps/web/src/new-api/shelter/index.ts
apps/web/src/new-api/sido/index.ts
apps/web/src/new-api/sigungu/index.ts
apps/web/src/new-site/search/card/AnimalCard.tsx
Remove the unused @vercel/remote-nx integration and stale Vercel configuration.
  • Delete the @vercel/remote-nx dev dependency from package.json and its lockfile entries.
  • Remove vercel.json configuration that is no longer needed now that routing is handled via the Next.js app router.
  • Ensure the example env file for the web app reflects the new server-side key usage (structure updated in diff even if contents are minimal).
package.json
package-lock.json
vercel.json
apps/web/.env.example

Possibly linked issues

  • [area:vercel-deploy] drop unused @vercel/remote-nx dep #64: They match on removing @vercel/remote-nx from package and lockfile; PR just includes extra API-related refactors.
  • #[area:vercel-deploy]: PR removes root vercel.json and shifts to Next-based zero-config Vercel config, satisfying the vercel.json removal issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@nx-cloud

nx-cloud Bot commented Apr 13, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b610789

Command Status Duration Result
nx build web ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-13 13:35:43 UTC

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In the Next route handler, context.params is not a promise in the app router; you can remove the Promise type and await and type it as { params: { path: string[] } } to match Next’s handler signature.
  • The new popfile1popfile8 fields are all modeled on the same interface entry that used to be a single popfile; if the upstream API doesn’t guarantee at least one image, consider marking popfile1 as optional and/or handling a missing image in AnimalCard to avoid runtime issues.
  • In the proxy route, you might want to propagate the original request’s signal to fetch (e.g., fetch(upstreamUrl, { signal: request.signal, ... })) so upstream requests are aborted when the client disconnects.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the Next route handler, `context.params` is not a promise in the app router; you can remove the `Promise` type and `await` and type it as `{ params: { path: string[] } }` to match Next’s handler signature.
- The new `popfile1``popfile8` fields are all modeled on the same interface entry that used to be a single `popfile`; if the upstream API doesn’t guarantee at least one image, consider marking `popfile1` as optional and/or handling a missing image in `AnimalCard` to avoid runtime issues.
- In the proxy route, you might want to propagate the original request’s `signal` to `fetch` (e.g., `fetch(upstreamUrl, { signal: request.signal, ... })`) so upstream requests are aborted when the client disconnects.

## Individual Comments

### Comment 1
<location path="apps/web/app/api/data-go-kr/[...path]/route.ts" line_range="6-8" />
<code_context>
+const UPSTREAM_BASE =
+  'https://apis.data.go.kr/1543061/abandonmentPublicService_v2';
+
+export async function GET(
+  request: NextRequest,
+  context: { params: Promise<{ path: string[] }> }
+) {
+  const serviceKey = process.env.DATA_GO_KR_SERVICE_KEY;
</code_context>
<issue_to_address>
**suggestion:** The `context.params` type and `await` usage are inconsistent with Next.js route handler conventions.

`context.params` should be typed as a plain object, not a `Promise`. Using `Promise<{ path: string[] }>` and `await` here misrepresents the actual type and can mislead TypeScript and future readers. Please update the signature to `context: { params: { path: string[] } }` and destructure with `const { path } = context.params;`.

Suggested implementation:

```typescript
export async function GET(
  request: NextRequest,
  context: { params: { path: string[] } }
) {

```

```typescript
  const { path } = context.params;

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +6 to +8
export async function GET(
request: NextRequest,
context: { params: Promise<{ path: string[] }> }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The context.params type and await usage are inconsistent with Next.js route handler conventions.

context.params should be typed as a plain object, not a Promise. Using Promise<{ path: string[] }> and await here misrepresents the actual type and can mislead TypeScript and future readers. Please update the signature to context: { params: { path: string[] } } and destructure with const { path } = context.params;.

Suggested implementation:

export async function GET(
  request: NextRequest,
  context: { params: { path: string[] } }
) {
  const { path } = context.params;

@fray-cloud

Copy link
Copy Markdown
Owner Author

Superseded by #73 — full #62#67 chain lands via #73.

@fray-cloud fray-cloud closed this Apr 13, 2026
@fray-cloud fray-cloud deleted the deploy/64-drop-remote-nx branch April 13, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant