refactor base(url) middleware