Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

When hosting the site in a sub folder, blog slugs fail to load .css and .js #861

Open
staus opened this issue Aug 28, 2019 · 4 comments
Open
Labels

Comments

@staus
Copy link

staus commented Aug 28, 2019

Describe the bug
When hosting the site in a sub folder, blog slugs fail to load .css and .js.
When testing locally, everything seems to be working.
index.svelte and about.svelte work fine and the blog post json content load fine. The only thing that fails is the css and js files. It looks like to me, that there is injected a "client" directory into the url.

To clarify:
This works:

This fail:

Logs
GET https://www.[domain].com/[sapper-site]/client/[slug].e85b6711.css net::ERR_ABORTED 400
GET https://www.[domain].com/[sapper-site]/client/[slug].e85b6711.js net::ERR_ABORTED 400

To Reproduce
in server.js

polka() // You can also use Express
	.use(
		'/[sapper-site]', // <------- Add this line 

In package.json

{
	"scripts": {
		"export": "sapper export --legacy --basepath [sapper-site]", <------- Modify
	}
}

(configuration for Netlify) In the root/static folder of an existing site, create a file called _redirects
/[sapper-site]/* https://[sapper-netlify-project].netlify.com/[sapper-site]/:splat 200

Expected behavior
Blog posts should just work

@Conduitry
Copy link
Member

I can't reproduce this when serving an exported site locally from a custom base URL. Can you? Or does this only happen on Netlify? What is that _redirects file intended to do?

@khrome83
Copy link

khrome83 commented Aug 30, 2019 via email

@staus
Copy link
Author

staus commented Aug 31, 2019

@Conduitry the netlify file is placed on the root site, to tell it that this folder is another ecosystem. You can read more here: https://www.netlify.com/docs/redirects/
I don't believe that has anything to do with the issue. It's just a technical detail I thought I'd leave in for the setup.

This only happens after I deploy to a server. Locally it seems to redirect fine to the sub folders. Sorry important detail, I'll add it to the issue.

@Conduitry
Copy link
Member

It looks like to me, that there is injected a "client" directory into the url.

That is the correct path to files. After you export, they live at __sapper__/export/[whatever]/client/....

I also noticed that in your logs, you're getting 400s, not 404s, which seems to indicate that there's more going on than just the files not being there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants