Reputation: 11
I'm a newbie
I'm trying to deploy a Nextjs website to Vercel, everything works properly when I run and build it locally but then when the application is building on Vercel, I get this error from Vercel logs
Failed to compile.
./config/serverUtils.ts:53:17
Type error: Type '{ type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; universe_domain: string; }' is not assignable to type 'JWTInput | ExternalAccountClientOptions | undefined'.
Object literal may only specify known properties, and 'auth_uri' does not exist in type 'JWTInput | ExternalAccountClientOptions'.
51 | client_email: data.client_email,
52 | client_id: data.client_id,
> 53 | auth_uri: data.auth_uri,
| ^
54 | token_uri: data.token_uri,
55 | auth_provider_x509_cert_url: data.auth_provider_x509_cert_url,
56 | client_x509_cert_url: data.client_x509_cert_url,
Error: Command "npm run build" exited with 1
I'm confused as I checked the interface for JWTInput from googleapis and auth_uri
exist in the interface, I don't know how to solve this error and would really appreciate help in solving the issue?
Below is the full code producing the error ./config/serverUtils.ts
"use server"
///This contains utility functions that are strictly for server based components
///Libraries -->
import { google } from "googleapis";
import { Readable } from "stream";
///Commencing the code
//Declaring the neccesary variables
const data = {
type: process.env.NEXT_PUBLIC_TYPE!,
project_id: process.env.NEXT_PUBLIC_PROJECT_ID!,
private_key_id: process.env.NEXT_PUBLIC_PRIVATE_KEY_ID!,
private_key: process.env.NEXT_PUBLIC_PRIVATE_KEY!.replace(/\\n/g, '\n'),//process.env.PRIVATE_KEY.replace(/\\n/g, '\n'),
//private_key: JSON.parse(process.env.NEXT_PUBLIC_PRIVATE_KEY!),
client_email: process.env.NEXT_PUBLIC_CLIENT_EMAIL!,
client_id: process.env.NEXT_PUBLIC_CLIENT_ID!,
auth_uri: process.env.NEXT_PUBLIC_AUTH_URI!,
token_uri: process.env.NEXT_PUBLIC_TOKEN_URI!,
auth_provider_x509_cert_url: process.env.NEXT_PUBLIC_AUTH_PROVIDER_X509_CERT_URL!,
client_x509_cert_url: process.env.NEXT_PUBLIC_CLIENT_X509_CERT_URL!,
universe_domain: process.env.NEXT_PUBLIC_UNIVERSE_DOMAIN!,
}
//console.log("Google Credentials: ", GoogleCredentials)
///This function allows one to perform CRUD operation using Google Drive
class GoogleDriveCRUD {
private oauth2client
private drive
constructor() {
this.oauth2client = new google.auth.GoogleAuth({
credentials: {
type: data.type,
project_id: data.project_id,
private_key_id: data.private_key_id,
private_key: data.private_key,//process.env.PRIVATE_KEY.replace(/\\n/g, '\n'),
client_email: data.client_email,
client_id: data.client_id,
auth_uri: data.auth_uri,
token_uri: data.token_uri,
auth_provider_x509_cert_url: data.auth_provider_x509_cert_url,
client_x509_cert_url: data.client_x509_cert_url,
universe_domain: data.universe_domain,
},
scopes: ["https://www.googleapis.com/auth/drive"],
});
//this.oauth2client.setCredentials({ refresh_token: refreshToken })
this.drive = google.drive({
version: "v3",
auth: this.oauth2client
})
}
//This function is used to add a file to GDrive
public async addFile(file: File, folderId: string | void) {
try {
const fileBuffer = file.stream();
//const mimeType = mime.getType(file.name);
const fileMetadata = {
name: file.name, // The name of the file to be uploaded
parents: folderId ? [folderId] : undefined, // The ID of the folder where the file should be uploaded
mimeType: file.type,
};
const media = {
mimeType: file.type,//'application/octet-stream',
body: Readable.from(fileBuffer),
//body: fileBuffer
};
const response = await this.drive.files.create({
requestBody: fileMetadata,
media: media,
fields: "id, imageMediaMetadata",
})
console.log("Response 1: ", response)
//console.log("Response 1: ", response.imageMediaMetadata)
return response.data
} catch (error) {
console.log(error)
}
}
//This function helps delete a file from GDrive
public async deleteFile(driveId: string) {
try {
const response = await this.drive.files.delete({
fileId: driveId
})
const res = await this.drive.files.get({
fileId: ""
})
console.log(response)
//console.log("Response: ", response.data)
} catch (error) {
console.log(error)
}
}
}
I have tried browsing and haven't found anything helpful, Please I would really appreciate any help in solving the bug. Thanks!
Upvotes: -1
Views: 70
Reputation: 1022
can you please remove or comment out these properties and try:
auth_uri: data.auth_uri,
token_uri: data.token_uri,
auth_provider_x509_cert_url: data.auth_provider_x509_cert_url,
client_x509_cert_url: data.client_x509_cert_url,
universe_domain: data.universe_domain,
`
Upvotes: 1