不同添加文件 不用写corsfilter
在thingsboard.yml下 修改(大概在485行左右)
# spring CORS configuration spring.mvc.cors: mappings: # Intercept path "[/api/**]": #Comma-separated list of origins to allow. '*' allows all origins. When not set,CORS support is disabled. #allowed-origins: "*" allowed-origin-patterns: "*" #改这里 #Comma-separated list of methods to allow. '*' allows all methods. allowed-methods: "*" #Comma-separated list of headers to allow in a request. '*' allows all headers. allowed-headers: "*" #How long, in seconds, the response from a pre-flight request can be cached by clients. max-age: "1800" #Set whether credentials are supported. When not set, credentials are not supported. allow-credentials: "true"
将已有的allowed-origins改成 allowed-orgin-patterns即可(两者不能共存)