Cho mình hỏi mọi người thưởng xử lý cors ở Golang như thế nào, mình đang xử dụng nginx và viết service để chạy go trên server
– Add các header cần thiết ( failed )
– Dùng package cors ( failed )
Rất cảm ơn mọi người
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nếu bạn muốn config CORS trong code, thì có thể tham khảo middleware này cho Gin nhé, các framework khác thì cũng gần tương tự:
mình cũng có config như vậy nhưng o local mình call vẫn bị dính cors á bác , bác có gặp trường hợp ở local ko
Như mình đang làm là tất cả cấu hình cors sẽ nằm ở trên nginx hết, vì nó rất tiện, có 10 con server go thì cũng chỉ cần cấu hình 1 con nginx là xong, update rổi restart cũng rất dễ
bác có thể share mình cấu hình nginx của bác đc ko
mình cảm ơn bác trước
mình hay tham khảo ở đây bạn ạ: https://michielkalkman.com/snippets/nginx-cors-open-configuration/
Cấu hình của mình là:
cho mình hỏi thêm bác config như vầy ở local call có bị dính cors ko
Ở local thì không có nginx bạn ạ, mình connect thẳng đến go luôn