correction request

This commit is contained in:
2026-05-16 11:23:31 +02:00
parent 43105f6bdc
commit 39d5e5d269
3 changed files with 52 additions and 140 deletions
@@ -29,7 +29,7 @@ export interface PostizMediaItem {
export interface PostizPost {
id: string;
content: string;
status: "QUEUE" | "PUBLISHED" | "ERROR" | "DRAFT";
state: "QUEUE" | "PUBLISHED" | "ERROR" | "DRAFT";
publishDate: string;
integration?: PostizIntegration;
integrations?: PostizIntegration[];
@@ -63,14 +63,20 @@ const PostizContext = createContext<PostizContextValue>({
});
function createClient(apiKey: string, baseUrl: string): AxiosInstance {
return axios.create({
baseURL: baseUrl,
const normalizedUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
const instance = axios.create({
baseURL: normalizedUrl,
headers: {
Authorization: apiKey,
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
timeout: 15000,
});
instance.interceptors.request.use((config) => {
console.log(">>> REQUEST:", config.method?.toUpperCase(), (config.baseURL || "") + (config.url || ""));
return config;
});
return instance;
}
export function PostizProvider({ children }: { children: React.ReactNode }) {
@@ -85,7 +91,7 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
const storedKey = await SecureStore.getItemAsync(API_KEY_STORAGE);
const storedUrl = await SecureStore.getItemAsync(BASE_URL_STORAGE);
if (storedKey) {
const url = storedUrl || DEFAULT_BASE_URL;
const url = (storedUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
setApiKey(storedKey);
setBaseUrl(url);
setClient(createClient(storedKey, url));