add headers for cross domain
use ret
huge refacotr