Skip to content

Commit

Permalink
Merge pull request geelen#29 from kantenkugel/master
Browse files Browse the repository at this point in the history
Fixed crawling of projects with publicPath != "/"
  • Loading branch information
geelen authored May 26, 2017
2 parents 35e42ee + 6a11bee commit 7c3d166
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export default class Server {
})

// Yes I just copied most of this from react-scripts ¯\_(ツ)_/¯
app.use(historyApiFallback({
index: '/200.html',
disableDotRule: true,
htmlAcceptHeaders: ['text/html'],
}))
app.use(publicPath, express.static(baseDir, { index: '200.html' }))
app.use(publicPath,
historyApiFallback({
index: '/200.html',
disableDotRule: true,
htmlAcceptHeaders: ['text/html'],
}),
express.static(baseDir, { index: '200.html' })
)

if (proxy) {
if (typeof proxy !== "string") throw new Error("Only string proxies are implemented currently.")
Expand Down
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default () => {

const server = new Server(buildDir, basename, 0, pkg.proxy)
server.start().then(() => {
const crawler = new Crawler(`http://localhost:${server.port()}/`, snapshotDelay, options)
const crawler = new Crawler(`http://localhost:${server.port()}${basename}`, snapshotDelay, options)
return crawler.crawl(({ urlPath, html }) => {
if (!urlPath.startsWith(basename)) {
console.log(`❗ Refusing to crawl ${urlPath} because it is outside of the ${basename} sub-folder`)
Expand Down

0 comments on commit 7c3d166

Please sign in to comment.