I tried all the suggestions from here like use of config.setAllowedOrigins instead of config.addAllowed() but in my case I had
config.setAllowedOrigins
config.addAllowed()
@CrossOrigin(origins = "*")
added before my controller which was causing this. Removing this resolved the error.