1. Run Aiminaabee
Start the API, allow CORS, and expose cart variant option fields.
On this page
Prerequisites
- Node.js v20.19.0+ or v22.12.0+
- Git CLI tool
- PostgreSQL
- A running Aiminaabee API
Start your Aiminaabee application so the Store API is available at http://localhost:3000. Open the vendor dashboard at http://localhost:3000/app, sign in, and confirm you have a publishable API key, region, and at least one product.
Ran to Errors?: Check out the troubleshooting guides for help.
Change CORS Configurations
The Aiminaabee application enforces Cross Origin Resource Sharing (CORS) security, which means you can only access the Aiminaabee API from configured origins.
The Next.js development server will run on port 3000 by default, which isn't a configured origin in the Aiminaabee application. To add it to configured origins, change the value of STORE_CORS and AUTH_CORS in the Aiminaabee application's .env file to the following:
plain
You can add other origins as well if necessary.
Learn more about CORS configurations in this guide.
Allow Cart Variant Option Fields
Aiminaabee restricts the fields that you can request from a Store API route through an allowed-fields list. Later in this guide, you'll retrieve a cart with its line items' variant options and its products' options, which the cart routes don't allow by default. Aiminaabee omits any field that isn't allowed from the response.
To allow those fields, create the file src/api/middlewares.ts in the Aiminaabee application with the following content:
ts
allowFields is available since the current Aiminaabee API. In earlier versions, write the middleware yourself, as explained in the Allowed Fields documentation.
The Store Cart API routes expand at most three levels of relations, so you can't request items.variant.options.option to get an option's title. Instead, you allow items.product.options, which holds the same titles at three levels, and match each variant option to its product option in the storefront. Learn more in the storeRelationsLimit configuration.
Important: Don't add a method or methods key to the middleware's object. Aiminaabee runs a method-scoped middleware after it validates the query parameters, so it has no effect there.
Learn more about allowed fields and how to override them in the Allowed Fields documentation.
Next: 2. Create Next.js app