Lately I have started learning NuxtJs and have encountered some problems with building my app. I have added serverMiddleware: ['~/api/index.js'] to my nuxt.config.js so that I have an express server on my index.js file. When i use yarn generate nuxt builds my files and creates the dist folder, which I copy then to my apache server and it works fine. The problem is that my express endpoints return 404. According to the the NuxtJs documentation this way will build only static files for me. How can I generate the static files to work with my express server. Is the only way to use node hosting? If I build the project with yarn build how does that affect SEO and crawling for Google?
Below is my /api/index.js in case i am doing something wrong.
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.json({
test: 'test'
});
});
app.get('/test', (req, res) => {
res.json({
test: 'test2'
})
});
module.exports = {
path: '/api',
handler: app
};