8000 Chose a file separator to replace square brackets [] · Issue #8013 · vercel/next.js · GitHub
[go: up one dir, main page]

Skip to content

Chose a file separator to replace square brackets [] #8013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the c 8000 ommunity.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gbreux opened this issue Jul 17, 2019 · 6 comments
Closed

Chose a file separator to replace square brackets [] #8013

gbreux opened this issue Jul 17, 2019 · 6 comments
Milestone

Comments

@gbreux
Copy link
gbreux commented Jul 17, 2019

Hi,

I just encounter an issue after migrated to the new dynamic routing feature and just found the bad news that AWS API gateway doesn't support square brackets in their path.

Feature request

Add a way to choose a query param separator to replace square brackets

Is your feature request related to a problem? Please describe.

AWS API gateway doesn't support square brackets in the filename so the dynamic routing is not usable on AWS

Describe the solution you'd like

Allowing us to chose what separator we would like could fit in the Nextjs config

dynamic_separator: '___$QUERY___'

Describe alternatives you've considered

I'd love to go on now but unfortunately, this is not an option for this project :/
If anyone has a solution to work around this issue, that would be great.

I've found a little ugly work around in the meantime:

  • Replace all known query in the out folder with the encodeURI version: (i.e encodeURI(/[hash]/) will become /%5Bhash%5D/
  • Decode the route in the lambda to read the file with the proper name fs.readFileSync(decodeURI(route))

That was indeed a bad idea, there is too many occurences and sometimes it needs to be as-is in the code.

Additional context

@gbreux gbreux changed the title Chose a file separator to replace quare brackets [] Chose a file separator to replace square brackets [] Jul 17, 2019
@Vadorequest
Copy link
Contributor

Related to a similar issue with a next+aws plugin serverless-nextjs/serverless-next.js#99

@c-st
Copy link
c-st commented Sep 10, 2019

That convention is not only causing trouble with AWS but also when serving from Spring Boot using Tomcat as application server. Also it seems that square brackets are not valid in URIs according to RFC3986:

https://tools.ietf.org/html/rfc3986?#section-3.2.2

A host identified by an Internet Protocol literal address, version 6
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]").  This is the only place where
square bracket characters are allowed in the URI syntax.  In
anticipation of future, as-yet-undefined IP literal address formats,
an implementation may use an optional version flag to indicate such a
format explicitly rather than rely on heuristic determination.

For a workaround: it could help to have a proxy (or middleware) rewrite URLs from **/[fooId] to **/%5BfooId%5D.

@timneutkens
Copy link
Member

Can you try next@canary it uses encoded urls.

@Timer Timer added this to the 9.0.x milestone Sep 10, 2019
@camiblanch
Copy link

Looks like encoded urls are now part of the non canary build as of 9.1.2

@Timer
Copy link
Member
Timer commented Nov 5, 2019

Closing as the latest has encoded URLs now.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
0