zoukankan      html  css  js  c++  java
  • 关于页面404

    刷新页面出现404异常,查看请求发现,请求的是“http://localhost:8080/renren-fast/product/category/list/tree”

    这个请求是不正确的,正确的请求是:http://localhost:10000/product/category/list/tree,

    修正这个问题:

    替换“staticconfigindex.js”文件中的“window.SITE_CONFIG[‘baseUrl’]”

    替换前:

    window.SITE_CONFIG['baseUrl'] = 'http://localhost:8080/renren-fast';
    

      

    替换后:

     window.SITE_CONFIG['baseUrl'] = 'http://localhost:88/api';
    

      

    http://localhost:88,这个地址是我们网关微服务的接口。

    这里我们需要通过网关来完成路径的映射,因此将renren-fast注册到nacos注册中心中,并添加配置中心

    application:
        name: renren-fast
      cloud:
        nacos:
          discovery:
            server-addr: 192.168.137.14:8848
    
          config:
            name: renren-fast
            server-addr: 192.168.137.8848
            namespace: ee409c3f-3206-4a3b-ba65-7376922a886d
    

      

    配置网关路由,前台的所有请求都是经由“http://localhost:88/api”来转发的,在“gulimall-gateway”中添加路由规则:

            - id: admin_route
              uri: lb://renren-fast
              predicates:
                - Path=/api/**
    

      

    但是这样做也引入了另外的一个问题,再次访问:http://localhost:8001/#/login,发现验证码不再显示:

    分析原因:

    1. 现在的验证码请求路径为,http://localhost:88/api/captcha.jpg?uuid=69c79f02-d15b-478a-8465-a07fd09001e6
    2. 原始的验证码请求路径:http://localhost:8001/renren-fast/captcha.jpg?uuid=69c79f02-d15b-478a-8465-a07fd09001e6

    在admin_route的路由规则下,在访问路径中包含了“api”,因此它会将它转发到renren-fast,网关在转发的时候,会使用网关的前缀信息,为了能够正常的取得验证码,我们需要对请求路径进行重写

  • 相关阅读:
    Git分支合并:Merge、Rebase的选择
    linux系统下MySQL表名区分大小写问题
    Spring Mvc和Spring Boot读取Profile方式
    Git删除远程分支
    TortoiseGit push免输密码
    git [command line] fatal: Authentication failed for
    Jenkins [Error] at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:192)
    FAIL
    WIN下修改host文件并立即生效
    MYSQL 创建数据库SQL
  • 原文地址:https://www.cnblogs.com/vincentmax/p/14381202.html
Copyright © 2011-2022 走看看