Rafael Lopez

geo

1 +const API_BASE = 'http://136.112.29.74/api/acteco';
2 +
3 +export async function GET({ url }) {
4 + const codigo = url.searchParams.get('codigo') || '';
5 + const gestion = url.searchParams.get('gestion') || '';
6 +
7 + if (!codigo) {
8 + return new Response(JSON.stringify({ error: 'Missing codigo' }), {
9 + status: 400,
10 + headers: { 'Content-Type': 'application/json' }
11 + });
12 + }
13 +
14 + const apiUrl = new URL(`${API_BASE}/${codigo}/ubigeos`);
15 + if (gestion) apiUrl.searchParams.set('gestion', gestion);
16 +
17 + try {
18 + const response = await fetch(apiUrl.toString());
19 + if (!response.ok) {
20 + return new Response(JSON.stringify({ error: `API error: ${response.status}` }), {
21 + status: response.status,
22 + headers: { 'Content-Type': 'application/json' }
23 + });
24 + }
25 + const data = await response.json();
26 + return new Response(JSON.stringify(data), {
27 + headers: { 'Content-Type': 'application/json' }
28 + });
29 + } catch (err) {
30 + return new Response(JSON.stringify({ error: 'Failed to fetch' }), {
31 + status: 500,
32 + headers: { 'Content-Type': 'application/json' }
33 + });
34 + }
35 +}
1 +const API_BASE = 'http://136.112.29.74/api/finfun';
2 +
3 +export async function GET({ url }) {
4 + const codigo = url.searchParams.get('codigo') || '';
5 + const gestion = url.searchParams.get('gestion') || '';
6 +
7 + if (!codigo) {
8 + return new Response(JSON.stringify({ error: 'Missing codigo' }), {
9 + status: 400,
10 + headers: { 'Content-Type': 'application/json' }
11 + });
12 + }
13 +
14 + const apiUrl = new URL(`${API_BASE}/${codigo}/ubigeos`);
15 + if (gestion) apiUrl.searchParams.set('gestion', gestion);
16 +
17 + try {
18 + const response = await fetch(apiUrl.toString());
19 + if (!response.ok) {
20 + return new Response(JSON.stringify({ error: `API error: ${response.status}` }), {
21 + status: response.status,
22 + headers: { 'Content-Type': 'application/json' }
23 + });
24 + }
25 + const data = await response.json();
26 + return new Response(JSON.stringify(data), {
27 + headers: { 'Content-Type': 'application/json' }
28 + });
29 + } catch (err) {
30 + return new Response(JSON.stringify({ error: 'Failed to fetch' }), {
31 + status: 500,
32 + headers: { 'Content-Type': 'application/json' }
33 + });
34 + }
35 +}
1 +const API_BASE = 'http://136.112.29.74/api/objeto';
2 +
3 +export async function GET({ url }) {
4 + const codigo = url.searchParams.get('codigo') || '';
5 + const gestion = url.searchParams.get('gestion') || '';
6 +
7 + if (!codigo) {
8 + return new Response(JSON.stringify({ error: 'Missing codigo' }), {
9 + status: 400,
10 + headers: { 'Content-Type': 'application/json' }
11 + });
12 + }
13 +
14 + const apiUrl = new URL(`${API_BASE}/${codigo}/ubigeos`);
15 + if (gestion) apiUrl.searchParams.set('gestion', gestion);
16 +
17 + try {
18 + const response = await fetch(apiUrl.toString());
19 + if (!response.ok) {
20 + return new Response(JSON.stringify({ error: `API error: ${response.status}` }), {
21 + status: response.status,
22 + headers: { 'Content-Type': 'application/json' }
23 + });
24 + }
25 + const data = await response.json();
26 + return new Response(JSON.stringify(data), {
27 + headers: { 'Content-Type': 'application/json' }
28 + });
29 + } catch (err) {
30 + return new Response(JSON.stringify({ error: 'Failed to fetch' }), {
31 + status: 500,
32 + headers: { 'Content-Type': 'application/json' }
33 + });
34 + }
35 +}
1 // Proxy para evitar CORS 1 // Proxy para evitar CORS
2 -const API_BASE = 'http://136.112.29.74/api/proyecto/search'; 2 +const API_BASE = 'http://136.112.29.74/api/search';
3 3
4 export async function GET({ url }) { 4 export async function GET({ url }) {
5 const q = url.searchParams.get('q') || ''; 5 const q = url.searchParams.get('q') || '';
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.