Using bracketed query parameters in an API call with Nuxtjs

I have an API call structured as follows:

fetch( '/api/test-api-call?page[size]=500&page[number]=1')

which should allow me to get a query argument of

{
  page: {
    size: '500',
    number: '1'
  }
}

However, it appears that when deployed to the Layer0 stack, the entire query string after the first [ is being stripped. So the logged URL ends up being /api/test-api-call?page and all other data on the query is totally stripped. This does not happen during local development trying to use layer0 dev or layer0 build && layer0 run.

The Nuxt app is using Express to serve an API endpoint back.
Code for app: GitHub - jeffpatzer/layer0-nuxt-api-test
Code for a deploy to test things:
https://jeff-patzer-my-nuxt-app-default.layer0.link/
Permalink => https://jeff-patzer-my-nuxt-app-master-21.free.layer0-perma.link/

Visit the deploy and enter the following into your JS console to test. All calls below would be using the permalink to avoid caching

Call fails

fetch( '/api/test-api-call?page[size]=500&page[number]=1')
fetch('/api/test-api-call?page%5Bsize%5D%3D500%26page%5Bnumber%5D%3D1')
// Resp
{"success":true,"data":{"page":""}}

Call works and returns correctly

fetch( '/api/test-api-call?page{size}=[500]&page{number}=[1]')
// Resp
{"success":true,"data":{"page{size}":"[500]","page{number}":"[1]"}}

fetch( '/api/test-api-call?page_size=500&page_number=1')
// Resp
{"success":true,"data":{"page_size":"500","page_number":"1"}}

Log line in the deploy server logs (notice the truncation)

Request details: GET
https://jeff-patzer-my-nuxt-app-master-21.free.layer0-perma.link/api/test-api-call?page=

The local app works as expected

fetch("http://localhost:3000/api/test-api-call?page[size]=500&page[number]=1")
// Resp
{"success":true,"data":{"page":{"size":"500","number":"1"}}}

It looks like there may indeed be an issue handling the open bracket in our serverless layer. We are investigating.

Mark, thanks for looking. Any success in fixing?

Nothing yet, it’s been on the backburner for the last week or so. I’ll see if we can get an update soon.

Hi Jeff, we have fixed this issue in v3.16.11. Thanks for reporting this!

1 Like

Testing the new version prove successful

1 Like