Coder Social home page Coder Social logo

Comments (10)

Ice-Hazymoon avatar Ice-Hazymoon commented on May 30, 2024

把 pwa 关了试试

'@nuxtjs/pwa',

from mikutools.

188 avatar 188 commented on May 30, 2024

关了没有问题,但是还想启用 pwa,这样怎么修改呀?

from mikutools.

188 avatar 188 commented on May 30, 2024

m3

还是有这个问题,只是在首页那边的没有了,在刷新或打开一个子页面时会存在这个问题?
现在是 pwa 关闭状态
还有什么办法吗?
我看你的站点也有一次301的问题

另外有点奇怪,每次打开 /lifecount 这样的url时会先转到 /lifecount/ 再打开/lifecount ,这样就产生了301

from mikutools.

Ice-Hazymoon avatar Ice-Hazymoon commented on May 30, 2024

不影响使用吧

from mikutools.

188 avatar 188 commented on May 30, 2024

是不影响使用,这个是什么原因引起的,能优化吗?

from mikutools.

Ice-Hazymoon avatar Ice-Hazymoon commented on May 30, 2024

参考:

https://webmasters.stackexchange.com/questions/35643/is-trailing-slash-automagically-added-on-click-of-home-page-url-in-browser/35646

https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#trailingslash

from mikutools.

188 avatar 188 commented on May 30, 2024

非常感谢上面的方法能解决这个问题,谢谢。
但是还是想不带后面的/ 又不想有301,打包发布到线上后还是不行
我看nuxt官方文档上面 router.trailingSlash=false 时是不加/ 的
实际上设置false时还是加上了,这个有什么办法解决吗?

from mikutools.

Ice-Hazymoon avatar Ice-Hazymoon commented on May 30, 2024

我没弄过这个需求,所以暂时不知道具体的解决方案,也对这部分不是很了解

请求 /lifecount/ 时,请求的具体内容是 /lifecount/index.html,如果末尾不加 /,访问的就是 lifecount 这个文件,我觉得应该是 http 服务器的特性

在新版本的 nginx(≥1.11.8) 中,可以通过设置 absolute_redirect off; 来解决

server {
    listen       8080;
    server_name  www.mydomain.com;
     
    absolute_redirect off;    #取消绝对路径的重定向
     
    root   html;
    ...
}

我也没试过这个方案,你可以尝试一下

from mikutools.

188 avatar 188 commented on May 30, 2024

我尝试了 absolute_redirect off;
router.trailingSlash=false 、 router.trailingSlash=true 、和不加这个配置
都还是不行,但在本地yarn dev 运行时 router.trailingSlash=false 是可以的
这个也很奇怪,感觉不是nginx这的问题,因为我输入 /lifecount/index.html时是打不开的,也就是走的应该是vue路由吧

from mikutools.

188 avatar 188 commented on May 30, 2024

我刚在本地测试了一下
用例1:
yarn dev 运行起来后,用nginx反向代理到 http://localhost:3000 一切正常
用例2:
yarn generate 打包后,用nginx指向本地目录 dist ,不管nginx怎么配置都城要301

从结果上分析,是没有生成前是没有具体的目录的,生成后确实访问的是目录下面的文件,但nginx不管怎么配置都好像不启作用一样

from mikutools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.