this is rewrite middleware for yc-servre