-
Hello Im unable to make a post request to my api endpoints whenever i have request header = {
"message": "stream is not readable",
"stack": "InternalServerError: stream is not readable\n at readStream (/Users/ace/Desktop/apps/web/app-api/node_modules/raw-body/index.js:178:17)\n at executor (/Users/ace/Desktop/apps/web/app-api/node_modules/raw-body/index.js:113:5)\n at new Promise (<anonymous>)\n at getRawBody (/Users/ace/Desktop/apps/web/app-api/node_modules/raw-body/index.js:112:10)\n at AsyncFunction.module.exports [as json] (/Users/ace/Desktop/apps/web/app-api/node_modules/@poppinss/co-body/lib/json.js:41:21)\n at BodyParserMiddleware.handle (/Users/ace/Desktop/apps/web/app-api/node_modules/@adonisjs/bodyparser/build/src/BodyParser/index.js:195:65)\n at Injector.callAsync (/Users/ace/Desktop/apps/web/app-api/node_modules/@adonisjs/fold/build/src/Ioc/Injector.js:124:30)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"
} Please any idea what might have gone wrong? Im running the app with inertia and vitejs. Route contentRoute.group(() => {
Route.post('/register', 'AuthController.register')
Route.post('/login', 'AuthController.login')
Route.post('/logout', 'AuthController.logout').middleware(['auth'])
Route.get('/password/recover', 'AuthController.recover')
Route.post('/password/reset', 'AuthController.reset')
Route.resource('users', 'UsersController').middleware({ '*': ['auth'] })
}).prefix('api/v1')
// FRONTEND
Route.get('/', ({ inertia }) => inertia.render('index'))
Route.get('/auth', ({ inertia }) => inertia.render('auth/index'))
Route.get('/create', ({ inertia }) => inertia.render('Home/create'))
Route.get('/create/build', ({ inertia }) => inertia.render('Home/build'))
// FRONTEND |
Beta Was this translation helpful? Give feedback.
Answered by
myckhel
Feb 21, 2023
Replies: 1 comment
-
I was able to fix the issue. i found out that body parser middleware was registered twice in the kernel file Server.middleware.register([
() => import('@ioc:Adonis/Core/BodyParser'),
() => import('@ioc:Adonis/Core/BodyParser'),
() => import('@ioc:EidelLev/Inertia/Middleware'),
]) After removing the duplicated middleware and then the issue was fixed. Thanks to those who tried to help. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
myckhel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was able to fix the issue.
i found out that body parser middleware was registered twice in the kernel file
After removing the duplicated middleware and then the issue was fixed.
Thanks to those who tried to help.