saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.97k stars 229 forks source link

Api routes #327

Closed AeShevch closed 1 year ago

AeShevch commented 1 year ago

Greetings! Migrated an existing nextjs application to nextron, but api routes don't work on production. Requesting them returns the html of the main page.

Dev works fine.

There is a warning in the console:

warn  - Statically exporting a Next.js application via `next export` disables API routes.
This command is meant for static-only hosts, and is not necessary to make your application static.
Pages in your application without server-side data dependencies will be automatically statically exported by `next build`, including pages powered by `getStaticProps`.
Learn more: https://nextjs.org/docs/messages/api-routes-static-export

How can I get them to work?

AeShevch commented 1 year ago

Got it, I need to use ipc. However, after following the example, I get the error:

Failed to compile ../node_modules/electron/index.js:1:0

Module not found: Can't resolve 'fs'

Import trace for requested module: ./pages/index.tsx