Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/api endpoints not picked up when running vercel dev #35

Closed
Strydom opened this issue Nov 26, 2023 · 3 comments
Closed

/api endpoints not picked up when running vercel dev #35

Strydom opened this issue Nov 26, 2023 · 3 comments

Comments

@Strydom
Copy link

Strydom commented Nov 26, 2023

👋🏻 Hello
Now that I have setup everything through Vercel, I have been trying to get local development to work when using vercel dev command.

I have setup the dev command to link to the existing project in vercel and when running vercel dev everything loads fine minus this small error...

Failed to resolve dependency: cross-fetch, present in 'optimizeDeps.include'

When I view a page without api calls the page renders.
When I view a page with api calls I get this error...

5:08:16 PM [vike][request(14)] HTTP request: /api/countryScores
5:08:16 PM [vike][request(14)] URL /api/countryScores doesn't match the route of any of your pages:
┌───────────────────────────────────────┬──────────────┬───────────────────────────────────────────────────────────┐
│ ROUTE                                 │ TYPE         │ DEFINED BY                                                │
├───────────────────────────────────────┼──────────────┼───────────────────────────────────────────────────────────┤
│ /                                     │ Route String │ /src/pages/landing/+route.ts > export default   │
│ /country/@countryCode                 │ Route String │ /src/pages/country/+route.ts > export default   │
│ /country/@countryCode/itinerary/@days │ Route String │ /src/pages/itinarary/+route.ts > export default │
│ /discover                             │ Route String │ /src/pages/discover/+route.ts > export default  │
│ /search                               │ Route String │ /src/pages/search/+route.ts > export default    │
└───────────────────────────────────────┴──────────────┴───────────────────────────────────────────────────────────┘

My project is setup with a src folder and an _api folder at the same level.

web/
  _api/
    countryScores.ts
  src/
    pages/
    ...

Related:

@Strydom
Copy link
Author

Strydom commented Nov 26, 2023

Switched the file name to api and it's working.
Anything you can do for the _api?

@magne4000
Copy link
Owner

Duplicate of #19

Anything you can do for the _api?

I need to see what can be done to circumvent this. There is a specific issue to track this #20 but I do not have much bandwidth to tackle this for now.

@Strydom
Copy link
Author

Strydom commented Nov 28, 2023

So api works locally but then it breaks the build in Vercel, i guess because of the known double build issues. _api works in Vercel.

but I do not have much bandwidth to tackle this for now.

Completely understand, story of my life.

I have a work around for now, i just have to keep switching between api and _api when working in different envs.

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

No branches or pull requests

2 participants