Closed thomaspeugeot closed 1 year ago
The only difference between this get and the other get is that this one requests a number, not a json .
Let's try with a json. Does not change the problem.
Another solution is to start from scratch the service. Follow what angular says.
@Injectable({
providedIn: 'root'
})
export class CommitNbFromBackService {
configUrl = 'api/github.com/fullstack-lang/gongdoc/go/v1/commitfrombacknb'
getCommitNbFromBack(): Observable<number> {
return this.http.get<number>(this.configUrl);
}
constructor(
private http: HttpClient
) {
}
}
same error
since this is a problem with the runtime vs debug version, I wonder wether it is related to he compiler options.
started a ng project from scratch. does not work.
I have to reproduce the bug with a very small project
Maybe this is because , both the tree component and the classdiagram component call the service simultaneously.
somethng, the same error occurs in debug mode on chrome (on 4200).
CORS error.
Request URL: http://localhost:8080/api/github.com/fullstack-lang/gongdoc/go/v1/commitfrombacknb
Request Method: GET
Status Code: 301 Moved Permanently
Referrer Policy: strict-origin-when-cross-origin
Content-Length: 36
Content-Type: text/html; charset=utf-8
Date: Mon, 13 Feb 2023 07:20:11 GMT
Location: /
The Status Code is from the go handling of static path.
r.NoRoute(func(c *gin.Context) {
fmt.Println(c.Request.URL.Path, "doesn't exists, redirect on /")
c.Redirect(http.StatusMovedPermanently, "/")
c.Abort()
})
One should debug the backend at this stage.
The is also this answer
https://stackoverflow.com/questions/30656293/angular-options-http-preflight-on-same-domain
You can't use localhost. I had to create an entry in my host file to associate 127.0.0.1 to an arbitrary name like mackbook. Then it should work for you.
all right, let's test some hypotheses.
if the problem is a CORS, then the problem occurs dring the PRE FLIGHT XML Http Request with "/". and it could be intercepted by the go debugger.
this is not the case, the call is not intercepted. the 301 is still present. "has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."
Using chrome with security disabled does not work either
open -n -a "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --args -disable-web-security
Http GET get http://localhost:8080/api/github.com/fullstack-lang/gongdoc/go/v1/commitfrombacknb
and the url becomes http://localhost:8080/