Closed Trenrod closed 3 months ago
Nailed it down to this line.
// /node_modules/astro/dist/core/routing/manifest/generator.js
function getRouteGenerator(segments, addTrailingSlash) {
const template = segments.map((segment) => {
return "/" + segment.map((part) => {
if (part.spread) {
return `:${part.content.slice(3)}(.*)?`; <= Removeing this ? allows it to build.
With ?:
/api/:path(.*)?
without:/api/:path(.*)
Seems like pathToRegexpError cannot handle the 1st one. I also dont understand any disadvantages of the 2nd on as I asume there are no grouping used?
Checking https://www.npmjs.com/package/path-to-regexp
They mentioning this example
Unnamed parameters
It is possible to define a parameter without a name. The name will be numerically indexed:
const regexp = pathToRegexp("/:foo/(.*)");
// keys = [{ name: 'foo', ... }, { name: '0', ... }]
According to this example the fixed line should look like this?
``return
:${part.content.slice(3)}/(.*)````
Any adjustments above make it fail in
// node_modules/astro/node_modules/path-to-regexp/dist/index.js:tokensToFunction
throw new TypeError("Expected \"".concat(token.name, "\" to be ").concat(typeOfMessage));
So to support it I would need to fix it here also?
I would look into it but I would need some guidance if im on the right track.
Hello @Trenrod. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro
will be closed if they have no activity within 3 days.
Can you please provide a working reproduction? It doesn't build, and the dev server works as expected
After trying to create a new project with a minimal reproduction I found out that the issue was that I was using an own path-to-regexp
. Which caused issues with the one supported by Astro.
/// package.json:dependencies
"path-to-regexp": "^7.0.0",
After removing it build + worked again.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Bug description
Logging
path
fails while trying to process/api/:path(.*)?
. The logic itself works as expected. All/api/...
calls terminates in[...path].ts
.My filestructure for
/api/
looks like this.File [...path].ts looks like this.
What's the expected result?
Build should be successfull.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-grnxjj?file=src%2Fpages%2Fapi%2F%5B...path%5D.ts
Participation