fixed #1312, #972, add cors support

Add cors support.