blurts-server icon indicating copy to clipboard operation
blurts-server copied to clipboard

Fix manual data broker resolution request

Open flozia opened this issue 1 year ago • 4 comments

Next.js redirects URLs with trailing slash /slug/ to /slug. On our local setup the redirect is also from http:// to https:// resulting in a failing POST request: net::ERR_SSL_PROTOCOL_ERROR.

flozia avatar Feb 28 '24 13:02 flozia

@flozia Not sure if any of this is correct, or if I'm misreading this, but would any of these trailing slash URLs be potentially suspicious or causing redirects (and potentially introducing tiny amounts of lag):

git grep -IPin "/['\"\`]" -- src ":(exclude)**.test.*" ":(exclude)**/mockL10n.ts" | grep -v "['\"]/['\"]" | grep -v "https://" | grep -v "\*/" | grep -v "a\[href\*="

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/automatic-remove/page.tsx:32:    redirect("/user/dashboard/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/manual-remove/page.tsx:22:    redirect("/user/dashboard/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/view-data-brokers/page.tsx:21:    redirect("/user/dashboard/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/welcome-to-plus/page.tsx:26:    redirect("/user/dashboard/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/welcome-to-plus/page.tsx:39:    redirect("/user/welcome/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/page.tsx:70:    return redirect("/user/welcome/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/settings/actions.ts:108:    revalidatePath("/user/settings/");
src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/settings/actions.ts:161:    revalidatePath("/user/settings/");
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:74:              signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:145:              signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:191:              signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:210:          signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:253:          signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/LandingView.tsx:324:            signUpCallbackUrl={`${process.env.SERVER_URL}/user/dashboard/`}
src/app/(proper_react)/(redesign)/(public)/page.tsx:21:    return redirect("/user/dashboard/");
src/app/components/client/SignInButton.tsx:28:        void signIn("fxa", { callbackUrl: "/user/dashboard/" });
src/app/components/client/toolbar/UserMenu.tsx:113:          href="/user/settings/"
src/app/deprecated/(authenticated)/admin/emails/page.tsx:23:  return redirect("./emails/" + EmailTemplateType.Verification);
src/app/functions/server/getExperiments.ts:25:      const features = await fetch(`${serverUrl}/v1/features/`, {
src/app/functions/server/onerep.ts:173:  const response: Response = await onerepFetch(`/profiles/${profileId}/`, {
src/client/js/partials/exposureScan.js:22:    const res = await fetch('/api/v1/scan/', {
src/client/js/partials/exposuresSetup.js:36:    const res = await fetch('/api/v1/user/exposures/', {
src/client/js/partials/landing.js:22:    newLocation.pathname = '/scan/'

pdehaan avatar Feb 28 '24 22:02 pdehaan

@pdehaan Thanks! I haven’t noticed this issue from breaking network requests anywhere else. However, I guess removing the trailing / won’t hurt and prevent potential unnecessary redirects.

@rhelmer Updated some 7604bb5. I could not find a linting rule that would catch this issue for us. We could write our own, but this does not break anything on prod. I’ve only made the changes to prevent the initially modified POST request URL from breaking locally. Another option would be to extend our automated test and not only run the smoke test — I created an issue for that.

flozia avatar Mar 01 '24 12:03 flozia

Risky counterpoint: https://nextjs.org/docs/pages/api-reference/next-config-js/trailingSlash

we could make /foo redirect to trailing slash /foo/ by default.

pdehaan avatar Mar 01 '24 12:03 pdehaan

Risky counterpoint: https://nextjs.org/docs/pages/api-reference/next-config-js/trailingSlash

we could make /foo redirect to trailing slash /foo/ by default.

@pdehaan I was thinking about this as well. I’m not sure I know enough about the pro and cons of each approach — any suggestion on which might be better?

flozia avatar Mar 05 '24 11:03 flozia