Is there a configuration in Github Pages that allows you to redirect everything to index.html for a Single Page App?

后端 未结 6 737
甜味超标
甜味超标 2021-01-17 15:28

I\'m trying to post my SPA app that works fine locally but when I push it to Github Pages, the interior pages don\'t register if you navigate to them directly.

For

6条回答
  •  生来不讨喜
    2021-01-17 16:07

    Well, there is an easy way out. Create a file in the root directory of your github pages repository named 404.html. Contents of that file should be:

    
    
    
        
        
        Loading...
    
    
        
    
    
    

    Basically, that script just uses Javascript to perform an XHR on index.html and make the content the document.
    I was reluctant to use document.body because I'm thinking of updating the whole document, but if it doesn't work, change doc variable to document.body.
    Not sure if this works, so I'll really appreciate feedback.
    Remember to use the same domain for the index.html else CORS will kick in.

提交回复
热议问题