Fix: Astro checkOrigin aus (Admin-Form-POSTs hinter Basic-Auth) + robustere Directus-Bestellnummer
This commit is contained in:
@@ -5,4 +5,5 @@ export default defineConfig({
|
|||||||
output: 'server',
|
output: 'server',
|
||||||
adapter: node({ mode: 'standalone' }),
|
adapter: node({ mode: 'standalone' }),
|
||||||
server: { host: '0.0.0.0', port: 4321 },
|
server: { host: '0.0.0.0', port: 4321 },
|
||||||
|
security: { checkOrigin: false },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function payload(d){
|
|||||||
export const listOrders = async () => (await api('/items/orders?limit=-1&sort=-created_at')).map(O);
|
export const listOrders = async () => (await api('/items/orders?limit=-1&sort=-created_at')).map(O);
|
||||||
export const getOrderById = async (id) => O(await api(`/items/orders/${id}`));
|
export const getOrderById = async (id) => O(await api(`/items/orders/${id}`));
|
||||||
export async function createOrder({ email, customer_name, items, total_cents, status='pending', address='' }) {
|
export async function createOrder({ email, customer_name, items, total_cents, status='pending', address='' }) {
|
||||||
const existing = await api('/items/orders?limit=1&sort=-id&fields=number');
|
const existing = await api('/items/orders?limit=1&sort=-number&fields=number');
|
||||||
let n = 1042; if (existing[0]?.number) { const m = parseInt(String(existing[0].number).split('-')[1]); if (!isNaN(m)) n = m; }
|
let n = 1042; if (existing[0]?.number) { const m = parseInt(String(existing[0].number).split('-')[1]); if (!isNaN(m)) n = m; }
|
||||||
const number = 'PMPNZNG-' + (n + 1);
|
const number = 'PMPNZNG-' + (n + 1);
|
||||||
const o = await api('/items/orders', { method:'POST', body: JSON.stringify({ number, email:email||'', customer_name:customer_name||'', status, total_cents:total_cents||0, items:items||[], address:address||'', created_at: new Date().toISOString() }) });
|
const o = await api('/items/orders', { method:'POST', body: JSON.stringify({ number, email:email||'', customer_name:customer_name||'', status, total_cents:total_cents||0, items:items||[], address:address||'', created_at: new Date().toISOString() }) });
|
||||||
|
|||||||
Reference in New Issue
Block a user