【发布时间】:2021-03-24 23:59:17
【问题描述】:
我有一个安卓应用。尝试使用具有多个重定向的深层链接。
第一个。重定向 - 当我打开这个 url (https://www.tiny.com/op/abRh4) Nginx 把这个 URL 重定向到
http://customdomain.com/internal
第二次重定向 - 此 Url (http://customdomain.com/internal/abRh4) 将自动(通过 API)重定向到 https://customdomain.com?screen-no=25&notification=show(长 url)
我终于想打开与https://customdomain.com?screen-no=25&notification=show 的深层链接。但是android用http://customdomain.com/internal/abRh4打开它
有人建议如何使用深度链接处理多个重定向(我们可以通过 nginx 配置将这个多个重定向处理成单个重定向吗)?
这是两个不同的服务器(第一个服务器 -> Nginx 重定向,第二个服务器 -> api 命中的位置)
nginx 配置
server {
listen 443 ssl http2;
server_name www.tiny.com;
location /op {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://customdomain.com/internal;
}
}
//this api will hit when we call http://customdomain.com/internal/abRh4
@GET
@Path("/{shortKey}")
@Produces({MediaType.TEXT_HTML})
public Response resolveShortUrl(@PathParam("shortKey") String shortUrlKey) {
UrlShortenerLogicHelper helper = new UrlShortenerLogicHelper();
try {
helper.openConnection();
URI url = new URI(helper.resolveShortUrl(shortUrlKey));
// return url like https://customdomain.com?screen-no=25¬ification=show
return Response.temporaryRedirect(url).build();
} catch(Exception e){}
}
【问题讨论】:
-
显示一些代码,您当前如何实现深度链接以及
WebView初始化。如果第一个重定向有效,为什么第二个不应该... -
@snachmsm 添加一些代码。可能这会有所帮助