Options
Configure Nuxt Medusa easily with the medusa
property.
export default { // Defaults options medusa: { baseUrl: process.env.MEDUSA_URL || 'http://localhost:9000', global: true, server: false, debug: false, publishableKey: "", auth: { type: "session", jwtTokenStorageKey: "medusa_auth_token", jwtTokenStorageMethod: "local" }, }}
For full configuration of @medusajs/js-sdk
check out the documentation here.
baseUrl
- Default:
http://localhost:9000
The url to which requests are made to.
global
- Default:
true
When set to true
it will register Medusa client globally through a plugin. Otherwise, first usage of useMedusaClient
or serverMedusaClient
will create a client and then use it from either the context or the event.
server
- Default:
false
When set to true
it will add a server utility serverMedusaClient
that allows to fetch data from Medusa from the server side.
apiKey
(Server only)
- Optional:
''
Optional API key used for authenticating admin requests, can be done from server or serverMedusaClient
only.
publishableKey
- Optional:
''
Required publishable API key used for storefront requests, you can generate this API key following the instructions here.
auth.type
- Default:
'session'
A string that specifies the user authentication method to use.
Possible types are:
session
: The user is authenticated with a cookie session.jwt
: The user is authenticated with a JWT token that's passed in the Bearer authorization header.
auth.jwtTokenStorageKey
- Default:
'medusa_auth_token'
A string that, when auth.type
is jwt
, specifies the key of the JWT token in the storage specified in the auth.jwtTokenStorageMethod
configuration.
auth.jwtTokenStorageMethod
- Default:
'local'
A string that, when auth.type
is jwt
, specifies where the JWT token is stored. Possible values are:
local
for the Local Storage.session
for the Session Storage.memory
to store it within the SDK for the current application's runtime.
globalHeaders
- Optional:
''
An object of key-value pairs indicating headers to pass in all requests, where the key indicates the name of the header field.
debug
- Default:
false
A boolean indicating whether to show debug messages of requests sent in the console. This is useful during development.
logger
- Default: JavaScript's console is used by default.
Replace the logger used by the JS SDK to log messages. The logger must be a class or object having the following methods:
error
: A function that accepts an error message to log.warn
: A function that accepts a warning message to log.info
: A function that accepts an info message to log.debug
: A function that accepts a debug message to log.