Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document standard NGINX config for deployment #236

Open
IlCallo opened this issue May 11, 2022 · 2 comments
Open

Document standard NGINX config for deployment #236

IlCallo opened this issue May 11, 2022 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@IlCallo
Copy link

IlCallo commented May 11, 2022

Quasar docs for SPA mode provide an example of how to configure nginx to serve a Quasar app
SSR mode doesn't really need it, as everything is server side generated, so nginx only needs to redirect everything to Quasar SSR Node process

SSG on the other side need a slightly different configuration, or nginx will answer with a 301 status whenever an URL without a pending slash is found
What we found to work for us was to add $uri/index.html explicitly and redirect to the 404 error page if nothing is found

location / {
        try_files $uri $uri/index.html $uri/ =404;
}

# Not sure if this is actually needed, or if nginx has some kind of smart default for this, doesn't seem so
# See http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
error_page /404.html;
@freddy38510
Copy link
Owner

freddy38510 commented May 11, 2022

I should definitely document how to setup a static server for SSG hosting. Thanks you for pointing this out to me.

After some good reading on the subject, I cannot recommend this configuration as it may hurt SEO due to duplicate content.

My advice is to stick to a consistent choice of whether or not to use a trailing slash. Then configure your server to do 301 redirects to add/remove the trailing slash.

Setting the Vue router strict option to true could help in this scenario. But then I would have to make sure that the extension generate the correct routes (with or without trailing slash).

I could possibly add an option to the extension for this.

What do you think ?

EDIT: I highly recommend you to read SvelteKit configuration about trailing slash. I think it point to the right direction.

@freddy38510 freddy38510 added the enhancement New feature or request label May 11, 2022
@IlCallo
Copy link
Author

IlCallo commented May 12, 2022

Interesting, I didn't really put much thoughts on URL duplication as Vue-router goes without trailing slash by default AFAIK, so people would explicitly need to add that trailing slash to cause that problem, but I understand your point

I'll take a look to the resources you provided, which seem really interesting, and adapt our configuration accordingly, thanks

About the "strict" option into Vue-router, I'm not really sure how much that's used and if it's worth making it configurable
This seems more like one of those things where an opinionated choice is fine, until there's a valid use case which requires it to be configurable

@freddy38510 freddy38510 added the documentation Improvements or additions to documentation label May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants