NextJS dynamic prefixUrl in Ky
Unanswered
Korat posted this in #help-forum
KoratOP
I am trying to create an instance of ky with a default prefix,
However, the url is a bit dynamic like .../api/{dynamicLocale}/...rest
Is there any way I can read NEXT_LOCALE from cookies and set it here ?
However, the url is a bit dynamic like .../api/{dynamicLocale}/...rest
Is there any way I can read NEXT_LOCALE from cookies and set it here ?
import ky from 'ky';
const locales: Record<string, string> = {
en: 'en-GB',
fr: 'fr-FR',
nl: 'nl-NL',
};
export const api = ky.create({
prefixUrl: 'here',
});
1 Reply
KoratOP
Or maybe, I could just use a wrapper around ky and handle the logic inside of it like I would do with fetch.