diff --git a/src/routes/articles/[id].ts b/src/routes/articles/[id].ts index f4b93a4..013bb73 100644 --- a/src/routes/articles/[id].ts +++ b/src/routes/articles/[id].ts @@ -13,7 +13,10 @@ export const GET: RequestHandler = async ({ params, url }) => { ).map(({ data }) => data)[0] if (article === undefined) { - return { status: 404 } + return { headers: { "Access-Control-Allow-Origin": "*" }, status: 404 } + } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { article: article as unknown as JSONObject }, } - return { body: { article: article as unknown as JSONObject } } } diff --git a/src/routes/articles/index.ts b/src/routes/articles/index.ts index 6bc4c3b..6da2308 100644 --- a/src/routes/articles/index.ts +++ b/src/routes/articles/index.ts @@ -48,6 +48,7 @@ export const GET: RequestHandler = async ({ url }) => { ) return { // status: 400, + headers: { "Access-Control-Allow-Origin": "*" }, body: { error: { query: queryError as unknown as JSONObject, @@ -64,5 +65,8 @@ export const GET: RequestHandler = async ({ url }) => { LIMIT ${limit} ` ).map(({ data }) => data) - return { body: { articles: articles as unknown as JSONObject[] } } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { articles: articles as unknown as JSONObject[] }, + } } diff --git a/src/routes/recherche/index.ts b/src/routes/recherche/index.ts index 1b7d8aa..371009e 100644 --- a/src/routes/recherche/index.ts +++ b/src/routes/recherche/index.ts @@ -48,6 +48,7 @@ export const GET: RequestHandler = async ({ url }) => { ) return { // status: 400, + headers: { "Access-Control-Allow-Origin": "*" }, body: { error: { query: queryError as unknown as JSONObject, @@ -72,8 +73,11 @@ export const GET: RequestHandler = async ({ url }) => { WHERE id = ${articleId} ` ).map(({ data }) => data) - return { body: { articles: articles as unknown as JSONObject[], q } } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { articles: articles as unknown as JSONObject[], q }, + } } } - return { body: {} } + return { headers: { "Access-Control-Allow-Origin": "*" }, body: {} } } diff --git a/src/routes/sections/[id].ts b/src/routes/sections/[id].ts index 7a6b34f..1059f06 100644 --- a/src/routes/sections/[id].ts +++ b/src/routes/sections/[id].ts @@ -13,7 +13,10 @@ export const GET: RequestHandler = async ({ params, url }) => { ).map(({ data }) => data)[0] if (section === undefined) { - return { status: 404 } + return { headers: { "Access-Control-Allow-Origin": "*" }, status: 404 } + } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { section: section as unknown as JSONObject }, } - return { body: { section: section as unknown as JSONObject } } } diff --git a/src/routes/sections/index.ts b/src/routes/sections/index.ts index 20a90af..75cef3f 100644 --- a/src/routes/sections/index.ts +++ b/src/routes/sections/index.ts @@ -48,6 +48,7 @@ export const GET: RequestHandler = async ({ url }) => { ) return { // status: 400, + headers: { "Access-Control-Allow-Origin": "*" }, body: { error: { query: queryError as unknown as JSONObject, @@ -64,5 +65,8 @@ export const GET: RequestHandler = async ({ url }) => { LIMIT ${limit} ` ).map(({ data }) => data) - return { body: { sections: sections as unknown as JSONObject[] } } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { sections: sections as unknown as JSONObject[] }, + } } diff --git a/src/routes/structs/[id].ts b/src/routes/structs/[id].ts index a3c871b..fff5c95 100644 --- a/src/routes/structs/[id].ts +++ b/src/routes/structs/[id].ts @@ -13,7 +13,10 @@ export const GET: RequestHandler = async ({ params, url }) => { ).map(({ data }) => data)[0] if (struct === undefined) { - return { status: 404 } + return { headers: { "Access-Control-Allow-Origin": "*" }, status: 404 } + } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { struct: struct as unknown as JSONObject }, } - return { body: { struct: struct as unknown as JSONObject } } } diff --git a/src/routes/structs/index.ts b/src/routes/structs/index.ts index e4c492b..5287bbf 100644 --- a/src/routes/structs/index.ts +++ b/src/routes/structs/index.ts @@ -48,6 +48,7 @@ export const GET: RequestHandler = async ({ url }) => { ) return { // status: 400, + headers: { "Access-Control-Allow-Origin": "*" }, body: { error: { query: queryError as unknown as JSONObject, @@ -64,5 +65,8 @@ export const GET: RequestHandler = async ({ url }) => { LIMIT ${limit} ` ).map(({ data }) => data) - return { body: { structs: structs as unknown as JSONObject[] } } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { structs: structs as unknown as JSONObject[] }, + } } diff --git a/src/routes/textes/[id].ts b/src/routes/textes/[id].ts index 11f5c56..6f7ff22 100644 --- a/src/routes/textes/[id].ts +++ b/src/routes/textes/[id].ts @@ -13,7 +13,10 @@ export const GET: RequestHandler = async ({ params, url }) => { ).map(({ data }) => data)[0] if (texte === undefined) { - return { status: 404 } + return { headers: { "Access-Control-Allow-Origin": "*" }, status: 404 } + } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { texte: texte as unknown as JSONObject }, } - return { body: { texte: texte as unknown as JSONObject } } } diff --git a/src/routes/textes/index.ts b/src/routes/textes/index.ts index 9544043..7ec6785 100644 --- a/src/routes/textes/index.ts +++ b/src/routes/textes/index.ts @@ -48,6 +48,7 @@ export const GET: RequestHandler = async ({ url }) => { ) return { // status: 400, + headers: { "Access-Control-Allow-Origin": "*" }, body: { error: { query: queryError as unknown as JSONObject, @@ -64,5 +65,8 @@ export const GET: RequestHandler = async ({ url }) => { LIMIT ${limit} ` ).map(({ data }) => data) - return { body: { textes: textes as unknown as JSONObject[] } } + return { + headers: { "Access-Control-Allow-Origin": "*" }, + body: { textes: textes as unknown as JSONObject[] }, + } }