Javascript 如何修复docker和nginx中的单页应用程序路由访问
我使用reactjs开发了我的单页应用程序。我们已经将它部署到Azure Devops云上,该云使用docker和nginx来提供html内容,并且运行良好。我正在使用带有HTML5历史API的reactrouter 当用户启动应用程序时,例如。https://myapp 它可以正常启动,但当我的应用程序被重定向到第三方登录页面(例如paypal)并重定向回带有url的应用程序时,例如。https://myapp/orders 它转到服务器,服务器总是获得根页面 我的Dockerfile内容:Javascript 如何修复docker和nginx中的单页应用程序路由访问,javascript,html,angularjs,reactjs,nginx,Javascript,Html,Angularjs,Reactjs,Nginx,我使用reactjs开发了我的单页应用程序。我们已经将它部署到Azure Devops云上,该云使用docker和nginx来提供html内容,并且运行良好。我正在使用带有HTML5历史API的reactrouter 当用户启动应用程序时,例如。https://myapp 它可以正常启动,但当我的应用程序被重定向到第三方登录页面(例如paypal)并重定向回带有url的应用程序时,例如。https://myapp/orders 它转到服务器,服务器总是获得根页面 我的Dockerfile内容:
# production stage
FROM nginx:stable-alpine as production-stage
#
COPY default.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
default.conf的内容
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
}
有没有办法使重定向返回到目标页面,例如。https://myapp/orders?