mirror of
https://github.com/supabase/supabase.git
synced 2026-10-10 20:05:06 +03:00
Delete apps/docs/content/troubleshooting/edge-function-404-error-response.mdx
This commit is contained in:
1 parent
493f23097d
commit
2f14415212
1 file changed
-160
@@ -1,160 +0,0 @@
|
||||
---
|
||||
title = "Edge Function 404 error response"
|
||||
topics = [ "functions" ]
|
||||
keywords = [ "404", "error" ]
|
||||
database_id = "a3cfff33-d640-4395-99bc-a110b7fb637c"
|
||||
|
||||
[[errors]]
|
||||
http_status_code = 404
|
||||
code = "NOT_FOUND"
|
||||
message = "Requested function was not found"
|
||||
---
|
||||
|
||||
A 404 response means the function name was unrecognized in the request URL:
|
||||
|
||||
```sh
|
||||
https://PROJECT_REF.supabase.co/functions/v1/UNRECOGNIZED_FUNCTION_NAME
|
||||
```
|
||||
|
||||
### Confirming the 404
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
**Browsers hide platform 404s:**
|
||||
|
||||
Browsers suppress platform 404 errors with [CORS message](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS/Errors#identifying_a_cors_issue), and the [Supabase JavaScript client](/docs/reference/javascript/introduction) surfaces only `Failed to send a request to the Edge Function`.
|
||||
|
||||
You cannot always confirm a 404 error from the browser alone. To verify, use one of the methods below.
|
||||
|
||||
</Admonition>
|
||||
|
||||
### Identifying 404s from the response message
|
||||
|
||||
From a non-browser client (cURL, Postman, Python...), a platform 404 returns:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": "NOT_FOUND",
|
||||
"message": "Requested function was not found"
|
||||
}
|
||||
```
|
||||
|
||||
If the body contains a different message, or something custom, your code executed and returned a 404 based on its logic.
|
||||
|
||||
Go to: [Your function returned a 404](#your-function-returned-a-404)
|
||||
|
||||
### Identifying 404s from the Function logs
|
||||
|
||||
Run the below query in the [Log Explorer](/dashboard/project/_/logs/explorer?q=SELECT%0A++req.pathname+AS+function_name,%0A++CASE%0A++++WHEN+metadata.execution_id+IS+NULL+THEN+%27unrecognized_function%27%0A++++ELSE+%27app_level_error%27%0A++END+AS+cause,%0A++timestamp%0AFROM%0A++function_edge_logs%0A++CROSS+JOIN+UNNEST(metadata)+AS+metadata%0A++CROSS+JOIN+UNNEST(metadata.request)+AS+req%0A++CROSS+JOIN+UNNEST(metadata.response)+AS+res%0AWHERE%0A++res.status_code+=+404%0ALIMIT+10;&its=&ite=):
|
||||
|
||||
```sql
|
||||
SELECT
|
||||
req.pathname AS function_name,
|
||||
CASE
|
||||
WHEN metadata.execution_id IS NULL THEN 'unrecognized_function'
|
||||
ELSE 'app_level_error'
|
||||
END AS cause,
|
||||
timestamp
|
||||
FROM
|
||||
function_edge_logs
|
||||
CROSS JOIN UNNEST(metadata) AS metadata
|
||||
CROSS JOIN UNNEST(metadata.request) AS req
|
||||
CROSS JOIN UNNEST(metadata.response) AS res
|
||||
WHERE
|
||||
res.status_code = 404
|
||||
LIMIT 10;
|
||||
```
|
||||
|
||||
The `function_name` column tells you exactly what path was requested, while `cause` indicates whether the platform rejected it or your code returned the 404.
|
||||
|
||||
Depending on the output, you can use this table to find the appropriate debugging section:
|
||||
|
||||
| Cause | Go to |
|
||||
|---|---|
|
||||
| `app_level_error` | [Your function returned a 404](#your-function-returned-a-404) |
|
||||
| `unrecognized_function` | [Unrecognized function](#unrecognized-function) |
|
||||
|
||||
---
|
||||
|
||||
# Actioning the error
|
||||
|
||||
## Your function returned a 404
|
||||
|
||||
Your function executed successfully at the platform level, but your code returned a 404 response itself.
|
||||
|
||||
**Example:**
|
||||
|
||||
```js
|
||||
return new Response(JSON.stringify({ error: 'Not found' }), {
|
||||
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
|
||||
status: 404, // <-- you set this
|
||||
});
|
||||
```
|
||||
|
||||
**How to fix:**
|
||||
|
||||
1. Search your function code for `404`. Look for explicit status codes on `Response` objects.
|
||||
2. Trace the condition that triggered it. If your function calls external APIs, it may be passing along errors returned by those services.
|
||||
3. Add logging before the return so future occurrences leave a trace:
|
||||
|
||||
```js
|
||||
console.error('Returning 404 - reason:', reason);
|
||||
```
|
||||
|
||||
See: [Error handling in Edge Functions](/docs/guides/functions/error-handling)
|
||||
|
||||
---
|
||||
|
||||
## Unrecognized function
|
||||
|
||||
The platform could not match your request URL to a deployed function.
|
||||
|
||||
### Check for typos
|
||||
|
||||
Make sure the function name in your request doesn't have:
|
||||
|
||||
- miscapitalization
|
||||
- em-dashes instead of dashes
|
||||
- misplaced characters
|
||||
- unnecessary slashes `///`
|
||||
|
||||
### Test from the dashboard
|
||||
|
||||
In the [Functions Dashboard](/dashboard/project/_/functions), select your function and use the test call option:
|
||||
|
||||

|
||||
|
||||
- **If the test call succeeds:** the problem is likely with how your client constructs the request. Double check your client code to see if it is overwriting the function name dynamically.
|
||||
|
||||
- **If the test call also 404s:** this can indicate an internal platform issue. Try redeploying the function.
|
||||
|
||||
### Redeploy the function
|
||||
|
||||
**Option A: Dashboard**
|
||||
|
||||
In the [Functions Dashboard](/dashboard/project/_/functions), open the function's code tab and redeploy:
|
||||
|
||||

|
||||
|
||||
**Option B: CLI**
|
||||
|
||||
If you set up the [Supabase CLI](/docs/guides/functions/quickstart) for your functions, you can run:
|
||||
|
||||
```sh
|
||||
# Redeploy a specific function
|
||||
supabase functions deploy FUNCTION_NAME
|
||||
|
||||
# Redeploy all functions
|
||||
supabase functions deploy
|
||||
```
|
||||
|
||||
If redeploying correct your issue or it continues to persist, open a ticket with [Supabase Support](/dashboard/support/new).
|
||||
|
||||
---
|
||||
|
||||
## Additional resources
|
||||
|
||||
- [Securing Edge Functions](/docs/guides/functions/auth)
|
||||
- [Debugging Edge Functions](/docs/guides/functions/logging)
|
||||
- [Quickstart: Dashboard deployment](/docs/guides/functions/quickstart-dashboard)
|
||||
- [Quickstart: CLI deployment](/docs/guides/functions/quickstart)
|
||||
Reference in new issue
Block a user