SuiiiOriginal post
Rank 4: Virtual Machine
I generate the url to file in NextJS server action. In client component, i use that url as src image. It works fine when I give Any permission! I want to protect only authorized users are able to access. How can I do so!```export function generateFileUrl(bucketId: string, fileId: string) {
const apiPath = /storage/buckets/${bucketId}/files/${fileId}/view?project=${PROJECT_ID};
const uri =new URL(API_DOMAIN_URL + apiPath);
return uri.toString()
}
Plain text
Summary
To protect a file URL in NextJS from unauthorized access, developers can add logic on the server side to check if the user is authorized to view the file. This can prevent manual entry of the URL for access.