grpc-web
                                
                                 grpc-web copied to clipboard
                                
                                    grpc-web copied to clipboard
                            
                            
                            
                        > It's working for grpc-web + protobuf.js. I hope it helps somebody.
          > It's working for grpc-web + protobuf.js. I hope it helps somebody.
import { ChunkParser, ChunkType } from "grpc-web-client/dist/ChunkParser" import { RPCImpl } from "protobufjs"; function rpcImpl(serviceName: string): RPCImpl { return async (method, requestData, callback) => { const request = await fetch(`${BASE_URL}/${serviceName}/${method.name}`, { method: "POST", headers: { "content-type": "application/grpc-web+proto", "x-grpc-web": "1", }, body: frameRequest(requestData), }); const buffer = await request.arrayBuffer(); const chunk = parseChunk(buffer); callback(null, chunk && chunk.data ? new Uint8Array(chunk.data) : null); }; } function parseChunk(buffer: ArrayBuffer) { return new ChunkParser() .parse(new Uint8Array(buffer)) .find(chunk => chunk.chunkType === ChunkType.MESSAGE); } function frameRequest(bytes: Uint8Array) { const frame = new ArrayBuffer(bytes.byteLength + 5); new DataView(frame, 1, 4).setUint32(0, bytes.length, false); new Uint8Array(frame, 5).set(bytes); return new Uint8Array(frame); }
Getting Failed to parse URL, Browser is not able to parse the URL
Fetch error: TypeError: Failed to execute 'fetch' on 'Window': Failed to parse URL from http://10.81.200.09:8000/loginService_package.LoginService/LoginMethod
at zone.js:1505:1
at proto.
Can someone please help in resolving this?
Many Thanks in advance
Originally posted by @rmv9490 in https://github.com/grpc/grpc-web/issues/80#issuecomment-1987124711
Thanks for re-posting the question!
FYI, murgatroid99@ provided a reply at: https://github.com/grpc/grpc-web/issues/80#issuecomment-1989010546
Is that helpful to you?
Thanks!
Closing due to inactivity. Feel free to re-open and follow up later if there are more updates. Thanks!