question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

basePath support broken in 1.19.0

See original GitHub issue

Describe the bug

When using the basePath and trailingSlash settings in next.config.js, the lambda creates an incorrect url in serverless-component 1.19.0-alpha.27

Actual behavior

With this config in next.config.js:

module.exports = {
  trailingSlash: true,
  basePath: "/nl"
  ...
}

When I do the following request: curl -v https://xxxxxxx.cloudfront.net/nl/zoek

I get this response:

< HTTP/2 308
< content-length: 0
< server: CloudFront
< date: Mon, 18 Jan 2021 08:41:00 GMT
< location: /nl%2Fzoek/
< refresh: 0;url=/nl%2Fzoek/

Expected behavior

When I do this response curl -v https://xxxxxxx.cloudfront.net/nl/zoek I expect the page zoek.tsx to be rendered.

Steps to reproduce

Configure basePath & trailingSlash & deploy with serverless-component 1.19.0

Versions

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dphangcommented, Jan 19, 2021

Fixed and published in @sls-next/serverless-component@1.19.0-alpha.28

0reactions
dphangcommented, Jan 19, 2021

Ah, thanks, I think it seems to be a similar issue as in: https://github.com/serverless-nextjs/serverless-next.js/pull/868. Because Next.js changed their internal redirect regex for Next 10.0.3 and then again in 10.0.4, we needed to add it to our list to remove since we have our own redirect for trailing slash (the reason is for better performance). We need to remove these from routes-manifest.json as they interfere with our own redirects:

  "redirects": [
    {
      "source": "/:file((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/]+\\.\\w+)/",
      "destination": "/:file",
      "internal": true,
      "statusCode": 308,
      "regex": "^(?:/((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/]+\\.\\w+))/$"
    },
    {
      "source": "/:notfile((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/\\.]+)",
      "destination": "/:notfile/",
      "internal": true,
      "statusCode": 308,
      "regex": "^(?:/((?!\\.well-known(?:/.*)?)(?:[^/]+/)*[^/\\.]+))$"
    }
  ],

It looks like for Next 10.0.4 there is a new internal property added so we can easily identify it.

Edit: as a side note, I also need to figure out why the e2e tests didn’t catch it as it should install the latest Next 10.0.x version each time (no cache or anything)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minecraft Bedrock's Mobile Controls are BROKEN in 1.19...
With Minecraft Bedrock Edition's recent update to 1.19.0 (The Wild Update), it came with some bugs, to the surprise of no one.
Read more >
Changelog - ReadonlyREST
basePath " kibana option implementation. Enhancement (KBN) Support full regex in kibana_hidden_apps rule. Enhancement Crash if Kibana is not patched.
Read more >
Changelog — drf-yasg 1.20.1 documentation
Support was dropped for Python 3.5, Django 2.0, Django 2.1, DRF 3.7 ... FIXED: fixed broken CSS when USE_SESSION_AUTH=False; FIXED: fixed implementation of ......
Read more >
rollup changelog
Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) ...
Read more >
4.8.38 - Release Status
Bug 2066675: Ensure IOPS setting is honoured on all supported block device types #437 ... Bug 1804230: fix broken ETCD link in user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found