0
0
Supabasecloud~20 mins

Invoking Edge Functions from client in Supabase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Edge Function Invoker Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What is the expected response when calling a Supabase Edge Function without authentication?

You have an Edge Function deployed on Supabase that requires user authentication. What will happen if a client calls this function without providing any authentication token?

AThe function returns a 404 Not Found error.
BThe function executes normally and returns the expected data.
CThe function returns a 500 Internal Server Error.
DThe function returns a 401 Unauthorized error response.
Attempts:
2 left
💡 Hint

Think about what happens when a protected resource is accessed without credentials.

Configuration
intermediate
2:00remaining
Which client code correctly calls a Supabase Edge Function named 'hello' with a JSON body?

You want to call an Edge Function named hello from your client app using Supabase's JavaScript client. Which code snippet correctly sends a POST request with a JSON body {"name": "Alice"}?

Aconst { data, error } = await supabase.functions.invoke('hello', { method: 'POST', body: { name: 'Alice' } });
Bconst { data, error } = await supabase.functions.invoke('hello', { method: 'POST', body: JSON.stringify({ name: 'Alice' }) });
Cconst { data, error } = await supabase.functions.invoke('hello', { body: JSON.stringify({ name: 'Alice' }) });
Dconst { data, error } = await supabase.functions.invoke('hello', { method: 'GET', body: JSON.stringify({ name: 'Alice' }) });
Attempts:
2 left
💡 Hint

Remember to specify the HTTP method and convert the body to a string.

Architecture
advanced
2:00remaining
What is the best way to secure sensitive data when invoking Supabase Edge Functions from a public client?

You have an Edge Function that accesses sensitive data. Your client app is public and runs in users' browsers. How should you protect the sensitive data when invoking the Edge Function?

AEmbed the sensitive data directly in the client code and send it with the request.
BMake the Edge Function public and rely on client-side validation to protect data.
CRequire authentication and verify user identity inside the Edge Function before returning sensitive data.
DUse a secret API key hardcoded in the client to authenticate requests to the Edge Function.
Attempts:
2 left
💡 Hint

Think about where sensitive data should be checked and who should have access.

🧠 Conceptual
advanced
2:00remaining
What happens if a Supabase Edge Function takes longer than 10 seconds to respond when invoked from the client?

Supabase Edge Functions have a maximum execution time limit. What is the expected behavior if a function exceeds this limit when called from a client?

AThe function is terminated and the client receives a timeout error response.
BThe function continues running in the background and the client receives a success response.
CThe function retries automatically until it completes successfully.
DThe client waits indefinitely until the function finishes.
Attempts:
2 left
💡 Hint

Consider what happens when a serverless function exceeds its time limit.

security
expert
2:00remaining
Which option correctly prevents Cross-Site Request Forgery (CSRF) attacks when invoking Supabase Edge Functions from a browser client?

You want to protect your Supabase Edge Functions from CSRF attacks when called from a browser. Which approach is the most effective?

AUse HTTP-only cookies for authentication and validate CSRF tokens in the Edge Function.
BRely on CORS settings alone to block unauthorized domains.
CInclude a secret API key in the client JavaScript code and check it in the Edge Function.
DDisable authentication on the Edge Function to avoid token issues.
Attempts:
2 left
💡 Hint

Think about how CSRF tokens and cookies work together to prevent attacks.