Skip to content

rewrite to sentry.io causes HTTP400 on Vercel #27118

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 community.

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
Naddiseo opened this issue Jul 12, 2021 · 3 comments
Closed

rewrite to sentry.io causes HTTP400 on Vercel #27118

Naddiseo opened this issue Jul 12, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template. please verify canary Please verify the issue with the latest canary branch.

Comments

@Naddiseo
Copy link

Naddiseo commented Jul 12, 2021

What version of Next.js are you using?

10.2.3

What version of Node.js are you using?

14

What browser are you using?

firefox

What operating system are you using?

ubuntu

How are you deploying your application?

vercel

Describe the Bug

(Not sure if this should be posted in the vercel repo or nextjs)

I'm using the rewrite functionality in next.config.js to proxy requests using sentry's tunnel option. This works fine in development, but on Vercel I'm getting HTTP400 Bad Request. However, there's no logs in Vercel for me to debug it.

I tried to make a request directly using wget, this is the output

  HTTP/1.1 400 Bad Request
  Content-Type: text/html; charset=UTF-8
  Connection: keep-alive
  Date: Mon, 12 Jul 2021 18:01:57 GMT
  Content-Length: 54
  server: Vercel
  x-vercel-id: pdx1::lpvk4-1626113609377-ff9f2c58b133
  strict-transport-security: max-age=63072000
  cache-control: s-maxage=0
Registered socket 3 for persistent reuse.
Parsed Strict-Transport-Security max-age = 63072000, includeSubDomains = false
URI content encoding = ‘UTF-8’
Skipping 54 bytes of body: [<html><title>Error 400 (Bad Request)!!1</title></html>] done.
2021-07-12 12:01:57 ERROR 400: Bad Request.

and the response headers in my browser from a sentry request:

HTTP/2 400 Bad Request
content-type: text/html; charset=UTF-8
date: Mon, 12 Jul 2021 18:14:26 GMT
content-length: 54
server: Vercel
x-vercel-id: pdx1::mhp66-1626113666128-ad3e845c91c8
strict-transport-security: max-age=63072000
cache-control: s-maxage=0
X-Firefox-Spdy: h2

Expected Behavior

Should proxy requests to sentry when deployed on vercel

To Reproduce

///next.config.js

const { withSentryConfig } = require("@sentry/nextjs");

const rewrites = async () => {
	const sentryUrl = new URL(process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN);
	const sentryProjectId = sentryUrl.pathname.replace("/", "");
	sentryUrl.pathname = `/api/${sentryProjectId}/envelope/`;
	const sentryProxyURL = sentryUrl.toString();
	const apiUrl = process.env.API_URL.trim();

	return [
	  {
	    source: "/:path*",
	    destination: "/:path*",
	  },
	  {
	    // API proxying to another vercel project works
	    source: "/api/:path*",
	    destination: `${apiUrl}/api/:path*`,
	    basePath: false,
	  },
	  {
	    // this proxying does not
	    source: "/sentry",
	    destination: sentryProxyURL,
	    basePath: false,
	  },
	]
};

const moduleExports = {
  rewrites,

  future: {
    webpack5: true,
    strictPostcssConfiguration: true,
  },
};
const SentryWebpackPluginOptions = { silent: true };

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);

In both of my sentry configs I also provide the tunnel: "/sentry" option

@Naddiseo Naddiseo added the bug Issue was opened via the bug report template. label Jul 12, 2021
@jankaifer jankaifer added the please verify canary Please verify the issue with the latest canary branch. label Nov 29, 2022
@jankaifer
Copy link
Contributor

Please verify that your issue can be recreated with next@canary.

Why was this issue marked with the please verify canary label?

We noticed the provided reproduction was using an older version of Next.js, instead of canary.

The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. You can think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces by running npm install next@canary and test it in your project, using your reproduction steps.

If the issue does not reproduce with the canary version, then it has already been fixed and this issue can be closed.

How can I quickly verify if my issue has been fixed in canary?

The safest way is to install next@canary in your project and test it, but you can also search through closed Next.js issues for duplicates or check the Next.js releases.

My issue has been open for a long time, why do I need to verify canary now?

Next.js does not backport bug fixes to older versions of Next.js. Instead, we are trying to introduce only a minimal amount of breaking changes between major releases.

What happens if I don't verify against the canary version of Next.js?

An issue with the please verify canary that receives no meaningful activity (e.g. new comments that acknowledge verification against canary) will be automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue, with the required reproduction, using next@canary.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction (following the above steps). Furthermore, you can upvote the issue (using the 👍 reaction on the topmost comment, instead of commenting "I have the same issue" etc.). Then, we can sort issues by engagement to prioritize.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every Next.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

@Naddiseo
Copy link
Author

Naddiseo commented Dec 2, 2022

Surprisingly it appears to work now if I remove the "tunnel" configuration option on the sentry server side config.

@Naddiseo Naddiseo closed this as completed Dec 2, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. please verify canary Please verify the issue with the latest canary branch.
Projects
None yet
Development

No branches or pull requests

2 participants