grpc-gatewayでのCORS対策
1988 ワード
https://github.com/grpc-ecosystem/grpc-gateway/issues/132
にある通りに、gorilla.handlers.CORS
が使えるので、ありがたく使わせていただく。
下記のように使う。
mux := runtime.NewServeMux(opts...)
newMux := handlers.CORS(
handlers.AllowedMethods([]string{"GET", "POST", "OPTIONS"}),
handlers.AllowedOrigins([]string{"http://localhost:3000"}),
handlers.AllowedHeaders([]string{"content-type", "x-foobar-key"}),
)(mux)
http.ListenAndServe(":8080", newMux)
Author And Source
この問題について(grpc-gatewayでのCORS対策), 我々は、より多くの情報をここで見つけました https://qiita.com/ushio_s/items/a442fa53a8a31b87a360著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .