Been trying for hours now, I cannot get the endpoint to create a customer extended:
- I am just trying to add the field "company" to the customer creation endpoint.
- I send a request from the signup from from the nextjs Starter and attach a "company" key in the formdata. I then POST this to the store/customers endpoint when creating the customer:
server:dev: error: Invalid request: Unrecognized fields: 'company'
server:dev: MedusaError: Invalid request: Unrecognized fields: 'company'
server:dev: at zodValidator (/node_modules/@medusajs/medusa/src/api/utils/zod-helper.ts:126:13)
server:dev: at processTicksAndRejections (node:internal/process/task_queues:95:5)
server:dev: at async validateBody (node_modules/@medusajs/medusa/src/api/utils/validate-body.ts:30:27) {
server:dev: __isMedusaError: true,
server:dev: type: 'invalid_data',
server:dev: code: undefined,
server:dev: date: 2024-09-23T09:57:39.506
server:dev: }
server:dev: ::1 - - [23/Sep/2024:09:57:39 +0000] "POST /store/customers HTTP/1.1" 400 95 "-" "node"
I adjusted my middleware to allow for this field:
import { defineMiddlewares } from "@medusajs/medusa";
import { z } from "zod";
export default defineMiddlewares({
routes: [
{
matcher: "/store/customers",
method: ["POST"],
additionalDataValidator: {
company: z.string().optional(),
},
},
],
});
I just cant make sense of it and the docs are not really helpful to be honest... Does anyone know what I am doing wrong? My #1 thought is that the matcher does not match correctly on the route / a different route is actually affected.