You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config/source/skills/cloud-functions/SKILL.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
name: cloud-functions
3
3
description: CloudBase function runtime guide for building, deploying, and debugging your own Event Functions or HTTP Functions. This skill should be used when users need application runtime code on CloudBase, not when they are merely calling CloudBase official platform APIs.
4
-
version: 2.18.0
4
+
version: 2.18.1
5
5
alwaysApply: false
6
6
---
7
7
@@ -50,6 +50,7 @@ Keep local `references/...` paths for files that ship with the current skill dir
50
50
- Confusing official CloudBase API client work with building your own HTTP function.
51
51
- Mixing Event Function code shape (`exports.main(event, context)`) with HTTP Function code shape (`req` / `res` on port `9000`).
52
52
- Treating HTTP Access as the implementation model for HTTP Functions. HTTP Access is a gateway configuration for Event Functions, not the HTTP Function runtime model.
53
+
- Assuming the access path created by `manageGateway(action="createAccess")` is stripped before the request reaches an HTTP Function. It is not rewritten by default, so exposing `/api/http-demo` or the default `/${targetName}` changes the path your handler must match unless you normalize the prefix yourself.
53
54
- Assuming `db.collection("name").add(...)` will create a missing document-database collection automatically. Collection creation is a separate management step.
54
55
- Forgetting that runtime cannot be changed after creation.
55
56
- Using cloud functions as the first answer for Web login.
Copy file name to clipboardExpand all lines: config/source/skills/cloud-functions/references/http-functions.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,52 @@ Before enabling anonymous access, confirm both of these:
150
150
151
151
If an external caller reports `EXCEED_AUTHORITY`, inspect the function permission first with `queryPermissions(action="getResourcePermission", resourceType="function")` before widening access.
152
152
153
+
### Gateway path mapping for HTTP Functions
154
+
155
+
`manageGateway(action="createAccess")` creates a public access path, but it does **not** rewrite that path to `/` before the request reaches your HTTP Function.
156
+
157
+
- Public access path `/api/http-demo` + request `GET /api/http-demo` -> your server normally receives pathname `/api/http-demo`
158
+
- Public access path `/api/http-demo` + request `GET /api/http-demo/health` -> your server normally receives pathname `/api/http-demo/health`
159
+
- If you omit `path`, `createAccess` defaults to `/${targetName}`, so a handler that only matches `/` will not automatically match the default public URL
160
+
161
+
When your implementation wants internal routes like `/` and `/health`, use one of these approaches:
162
+
163
+
1. Match the public path directly in your handler.
164
+
2. Strip a known public base path in code before routing.
if (pathname.startsWith(`${PUBLIC_BASE_PATH}/`)) {
181
+
returnpathname.slice(PUBLIC_BASE_PATH.length);
182
+
}
183
+
184
+
return pathname;
185
+
}
186
+
187
+
constserver=http.createServer((req, res) => {
188
+
consturl=newURL(req.url, "http://127.0.0.1");
189
+
constpathname=normalizePath(url.pathname);
190
+
191
+
if (req.method==="GET"&& pathname ==="/") {
192
+
// Handle public /api/http-demo as internal /
193
+
}
194
+
});
195
+
```
196
+
197
+
Do not assume `createAccess` gives you gateway rewrite behavior. If you need separate route-rewrite semantics, treat that as an explicit gateway-routing requirement and confirm the route capability first instead of guessing.
0 commit comments