Improve Netlify workflow documentation and preview server#8
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const requestUrl = new URL(req.url, `http://${req.headers.host ?? `localhost:${port}`}`); | ||
| let pathname = requestUrl.pathname; | ||
|
|
||
| if (pathname.endsWith("/")) { | ||
| pathname = `${pathname}index.html`; | ||
| } | ||
|
|
||
| const decodedPath = decodeURIComponent(pathname); | ||
| const safePath = normalize(join(outDir, decodedPath)); | ||
|
|
||
| if (!safePath.startsWith(outDir)) { |
There was a problem hiding this comment.
Strip leading slash before joining request path
The preview server never serves any file because decodedPath always begins with /, so join(outDir, decodedPath) returns the absolute decoded path (e.g. /index.html) and the subsequent startsWith(outDir) check fails. As a result every request is rejected with 403 and the preview server advertised in the README cannot be used at all. Remove the leading slash (or otherwise ensure the second argument to join is relative) before calling join so generated paths stay under outDir.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task