api change for weird cors
This commit is contained in:
parent
1a6bf08bde
commit
b92626b677
@ -154,6 +154,7 @@ Future<String> fetchBusinessData() async {
|
|||||||
//set defaults
|
//set defaults
|
||||||
String _hostname = 'localhost';
|
String _hostname = 'localhost';
|
||||||
const _port = 8000;
|
const _port = 8000;
|
||||||
|
Map<String, String> headers = {...headers, 'Access-Control-Allow-Methods': '*'};
|
||||||
|
|
||||||
final postgres = PostgreSQLConnection(
|
final postgres = PostgreSQLConnection(
|
||||||
Platform.environment['JOBLINK_POSTGRES_ADDRESS']!,
|
Platform.environment['JOBLINK_POSTGRES_ADDRESS']!,
|
||||||
@ -174,7 +175,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
'Hello, World!',
|
'Hello, World!',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/overview/jobs', (Request request) async {
|
app.get('/fbla-api/businessdata/overview/jobs', (Request request) async {
|
||||||
@ -231,10 +232,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
json.encode(postgresResult[0][0]),
|
json.encode(postgresResult[0][0]),
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/overview/types', (Request request) async {
|
app.get('/fbla-api/businessdata/overview/types', (Request request) async {
|
||||||
@ -269,10 +267,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
json.encode(output),
|
json.encode(output),
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/businessnames', (Request request) async {
|
app.get('/fbla-api/businessdata/businessnames', (Request request) async {
|
||||||
@ -289,10 +284,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
json.encode(postgresResult),
|
json.encode(postgresResult),
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/business/<business>',
|
app.get('/fbla-api/businessdata/business/<business>',
|
||||||
@ -338,10 +330,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
json.encode(result),
|
json.encode(result),
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata/businesses', (Request request) async {
|
app.get('/fbla-api/businessdata/businesses', (Request request) async {
|
||||||
@ -350,10 +339,7 @@ void main() async {
|
|||||||
if (request.url.queryParameters['businesses'] == null) {
|
if (request.url.queryParameters['businesses'] == null) {
|
||||||
return Response.badRequest(
|
return Response.badRequest(
|
||||||
body: 'query \'businesses\' required',
|
body: 'query \'businesses\' required',
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var filters = request.url.queryParameters['businesses']!.split(',');
|
var filters = request.url.queryParameters['businesses']!.split(',');
|
||||||
@ -383,10 +369,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
json.encode(output),
|
json.encode(output),
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/businessdata', (Request request) async {
|
app.get('/fbla-api/businessdata', (Request request) async {
|
||||||
@ -412,10 +395,7 @@ void main() async {
|
|||||||
var encoded = json.encode(result[0][0]);
|
var encoded = json.encode(result[0][0]);
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
encoded,
|
encoded,
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'text/plain'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'text/plain'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/logos/<logo>', (Request request, String logoId) {
|
app.get('/fbla-api/logos/<logo>', (Request request, String logoId) {
|
||||||
@ -426,19 +406,13 @@ void main() async {
|
|||||||
List<int> content = logo.readAsBytesSync();
|
List<int> content = logo.readAsBytesSync();
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
content,
|
content,
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'image/png'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'image/png'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error reading logo!');
|
print('Error reading logo!');
|
||||||
return Response.notFound(
|
return Response.notFound(
|
||||||
'logo not found',
|
'logo not found',
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'image/png'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'image/png'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -470,7 +444,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
id.toString(),
|
id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -480,7 +454,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/createlisting', (Request request) async {
|
app.post('/fbla-api/createlisting', (Request request) async {
|
||||||
@ -505,7 +479,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
id.toString(),
|
id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -515,7 +489,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/deletebusiness', (Request request) async {
|
app.post('/fbla-api/deletebusiness', (Request request) async {
|
||||||
@ -538,7 +512,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
id.toString(),
|
id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -548,7 +522,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/deletelisting', (Request request) async {
|
app.post('/fbla-api/deletelisting', (Request request) async {
|
||||||
@ -565,7 +539,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
id.toString(),
|
id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -575,7 +549,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/editbusiness', (Request request) async {
|
app.post('/fbla-api/editbusiness', (Request request) async {
|
||||||
@ -612,7 +586,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
business.id.toString(),
|
business.id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -622,7 +596,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/editlisting', (Request request) async {
|
app.post('/fbla-api/editlisting', (Request request) async {
|
||||||
@ -645,7 +619,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
listing.id.toString(),
|
listing.id.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -655,7 +629,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/signin', (Request request) async {
|
app.post('/fbla-api/signin', (Request request) async {
|
||||||
@ -671,7 +645,7 @@ void main() async {
|
|||||||
if (saltDb.isEmpty) {
|
if (saltDb.isEmpty) {
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'invalid username',
|
'invalid username',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -712,12 +686,12 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
token.toString(),
|
token.toString(),
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'invalid password',
|
'invalid password',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -761,7 +735,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
username,
|
username,
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -771,7 +745,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.post('/fbla-api/deleteuser', (Request request) async {
|
app.post('/fbla-api/deleteuser', (Request request) async {
|
||||||
@ -793,7 +767,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
username,
|
username,
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
} on JWTExpiredException {
|
} on JWTExpiredException {
|
||||||
print('JWT Expired');
|
print('JWT Expired');
|
||||||
@ -803,7 +777,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.unauthorized(
|
return Response.unauthorized(
|
||||||
'unauthorized',
|
'unauthorized',
|
||||||
headers: {'Access-Control-Allow-Origin': '*'},
|
headers: headers,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.get('/fbla-api/marinodev', (Request request) async {
|
app.get('/fbla-api/marinodev', (Request request) async {
|
||||||
@ -814,10 +788,7 @@ void main() async {
|
|||||||
|
|
||||||
return Response.ok(
|
return Response.ok(
|
||||||
content,
|
content,
|
||||||
headers: {
|
headers: {...headers, 'Content-Type': 'image/svg+xml'},
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Content-Type': 'image/svg+xml'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user