- Make sure that your
remix.config.js
file looks like this:
/**
* @type {import('@remix-run/dev/config').AppConfig}
*/
module.exports = {
appDirectory: 'app',
assetsBuildDirectory: 'public/build',
publicPath: '/build/',
serverBuildDirectory: 'api/_build', // original value 'build'
devServerPort: 8002,
ignoredRouteFiles: ['.*'],
}
- Make sure to add Vercel dependency in your package.json doing:
npm i @remix-run/vercel
- Create
api/index.js
at the root directory of your project with the following content:
const { createRequestHandler } = require("@remix-run/vercel");
module.exports = createRequestHandler({
build: require("./_build")
});
- Remember to ignore the output directory
/api/_build
in your .gitignore by adding the following line:
/api/_build
That's all! I hope this helps you out with the issue.