-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript error: The 'credentials' field on 'RequestInitializerDict' is not implemented." #75
Comments
I'll check this later 👀 |
@cxjava Thank you for reporting this issue. If it's a bug of wrangler, please send issue to wrangler's repository. (In that case, the same error will occur without syumai/workers)
I'm sorry, I don't know about it. |
Hi @syumai , Thank you for digging this issue!
Let's skip it, it is my assumption. I don't describe it very detail, make you confused! Sorry about that! I update the code, When I want to call third party API in the pages API, it will throw the package main
import (
"fmt"
"io"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/syumai/workers"
)
func main() {
r := chi.NewRouter()
r.Route("/api", func(r chi.Router) {
r.Get("/hello", func(w http.ResponseWriter, req *http.Request) {
name := req.URL.Query().Get("name")
if name == "" {
name = "Pages Functions"
}
fmt.Fprintf(w, "Hello, %s!", name)
})
r.Get("/hello2", func(w http.ResponseWriter, req *http.Request) {
// ❗👇here I call other service API, such as your deploy to pages.❗
resp, err := http.DefaultClient.Get(`https://cf-pages-demo-cxjava.pages.dev/api/hello`)
if err != nil {
fmt.Fprintf(w, "Hello, Hello world! plus "+err.Error())
}
defer resp.Body.Close()
body, err := io.ReadAll(req.Body)
fmt.Fprintf(w, "Hello, Hello world! plus remote "+string(body))
})
r.Get("/hello3", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Hello, Hello, Hello world!")
})
})
workers.Serve(r)
}
In the if I call my service in the local expected it will return but it throw exception. |
i have the same error, have you fixed this ? @cxjava |
I couldn't figure out why the import "github.com/syumai/workers/cloudflare/fetch" r.Get("/hello2", func(w http.ResponseWriter, req *http.Request) {
const url = "https://cf-pages-demo-cxjava.pages.dev/api/hello"
fetchReq, err := fetch.NewRequest(req.Context(), http.MethodGet, url, nil)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "err: %v", err)
return
}
cli := fetch.NewClient()
resp, err := cli.Do(fetchReq, nil)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "err: %v", err)
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
fmt.Fprintf(w, "Hello, Hello world! plus remote "+string(body))
}) |
Maybe the problem occurs around here... |
The problem is:
The solution is:
|
Hi @syumai , Thank you for building this great repository!
I try to deploy this tool to Cloudflare Pages.
When I want to deploy my repository into pages, I got this issue
JavaScript error: The 'credentials' field on 'RequestInitializerDict' is not implemented."
in my local and remote pages ENV.I search this error, like this issue, seems the Cloudflare Workers add the credentials automatically, Do you know how to disable it? Or can we manually deploy it to pages without use wrangler.
Can you help to check it? Thank you!
The text was updated successfully, but these errors were encountered: