This commit is contained in:
@@ -35,7 +35,24 @@ export default defineEventHandler(async (event) => {
|
||||
if (!body.url || !body.apiKey || !body.baseId || !body.tables) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'All fields are required: url, apiKey, baseId, tables'
|
||||
statusMessage: 'Missing required fields: url, apiKey, baseId, tables'
|
||||
});
|
||||
}
|
||||
|
||||
// Validate API token format - check for non-ASCII characters that would cause ByteString errors
|
||||
const apiKey = body.apiKey.trim();
|
||||
if (!/^[\x00-\xFF]*$/.test(apiKey)) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'API token contains invalid characters. Please ensure you copied the token correctly without any special formatting characters.'
|
||||
});
|
||||
}
|
||||
|
||||
// Additional validation for common token issues
|
||||
if (apiKey.includes('•') || apiKey.includes('…') || apiKey.includes('"') || apiKey.includes('"')) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'API token contains formatting characters (bullets, quotes, etc.). Please copy the raw token from NocoDB without any formatting.'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,23 @@ export default defineEventHandler(async (event) => {
|
||||
};
|
||||
}
|
||||
|
||||
// Validate API token format - check for non-ASCII characters that would cause ByteString errors
|
||||
const apiKey = body.apiKey.trim();
|
||||
if (!/^[\x00-\xFF]*$/.test(apiKey)) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'API token contains invalid characters. Please ensure you copied the token correctly without any special formatting characters.'
|
||||
};
|
||||
}
|
||||
|
||||
// Additional validation for common token issues
|
||||
if (apiKey.includes('•') || apiKey.includes('…') || apiKey.includes('"') || apiKey.includes('"')) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'API token contains formatting characters (bullets, quotes, etc.). Please copy the raw token from NocoDB without any formatting.'
|
||||
};
|
||||
}
|
||||
|
||||
console.log('[api/admin/nocodb-test.post] Testing NocoDB connection...');
|
||||
console.log('[api/admin/nocodb-test.post] URL:', body.url);
|
||||
console.log('[api/admin/nocodb-test.post] Base ID:', body.baseId);
|
||||
|
||||
Reference in New Issue
Block a user