Fix cross domain request issues & refacor

Signed-off-by: Albert Yu <dev.yufan@gmail.com>