Skip to content

Commit

Permalink
fix(cf): use relative redirect path
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Oct 11, 2023
1 parent 16c9be8 commit df9da05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion _routes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 1,
"include": ["/grapher/*"],
"exclude": []
"exclude": ["/grapher/embedCharts.js"]
}
6 changes: 5 additions & 1 deletion functions/grapher/[slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export const onRequestGet: PagesFunction = async (context) => {

// Redirect to lowercase slug
if (url.pathname !== url.pathname.toLowerCase()) {
return Response.redirect(url.pathname.toLowerCase() + url.search, 301)
const redirUrl = url.pathname.toLowerCase() + url.search
return new Response(null, {
status: 301,
headers: { Location: redirUrl },
})
}

const { search } = url
Expand Down

0 comments on commit df9da05

Please sign in to comment.