Just upgraded from 0.6 to 0.7 and can no longer access Browsersync/served site using pathPrefix option, throws Cannot GET error. Reverting to 0.6 restores normal behaviour.
Sample config file:
module.exports = function(eleventyConfig) {
eleventyConfig.addPassthroughCopy('assets');
return {
dir: {
input: 'src',
output: 'docs'
},
pathPrefix: '/project/',
dataTemplateEngine: 'njk',
htmlTemplateEngine: 'njk',
passthroughFileCopy: true
};
};
This file results in Cannot GET /project/ error. Chrome console also shows some errors as follows, not sure if relevant:
localhost/:7 Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash [...], or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
and
localhost/:1 Failed to load resource: the server responded with a status of 404 (Not Found)
I tried to compare the DEBUG=socket.io* output, and the difference between 0.6.0 and the newest one is this:
// 0.6.0
"routes":{"/mysubdir/":"./_site"}
// 0.7.1
"routes":{"/mysubdir/":"_site/mysubdir"}
it looks like EleventyServe.js is pointing to the wrong directory, @zachleat
@fewerflatlands , for now maybe you can override that behaviour in your config file, like this :
eleventyConfig.setBrowserSyncConfig({
server: {
baseDir: "_site/_eleventy_redirect",
routes: { "/mysubdir/": "./_site" }
}
});
Thanks @okitavera!
Iβll have a look.
This will be included with 0.7.2
Many thanks!
@zachleat I noticed that even without pathPrefix, the eleventy --serve command does not work for me in 0.7.1 (I get the same CSP errors).
I've just been following the guides so my site only consists of:
.
βββ README.md
βββ _includes
β βββ layout.njk
βββ _site
β βββ README
β βββ index.html
βββ package-lock.json
βββ package.json
@robdodson can you file another issue? I canβt reproduce but we might be expecting different things from the feature?
Your project structure works as expected for me with:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
{{ content | safe }}
</body>
</html>
---
layout: layout.njk
---
# Test
dskljfkl
npx eleventy --serve --pathprefix=/test/ and navigating to http://localhost:8080/test/README/ works as expected and shows the rendered outputnpx eleventy --serve and navigating to http://localhost:8080/README/ works as expected and shows the rendered outputJust as information until 0.7.2 is released, from https://github.com/11ty/eleventy/issues/384#issuecomment-459895721 it would appear that --pathprefix is working fine but setting the pathprefix in configuration file (.eleventy.js) is what was broken in 0.7.0 and 0.7.1.
my mistake, I was just putting the wrong url in :P
Most helpful comment
This will be included with 0.7.2