Skip to content

server: reformat/refactor around redirects (again)#1009

Merged
jorgeorpinel merged 9 commits into
masterfrom
server/redirects
Feb 21, 2020
Merged

server: reformat/refactor around redirects (again)#1009
jorgeorpinel merged 9 commits into
masterfrom
server/redirects

Conversation

@jorgeorpinel
Copy link
Copy Markdown
Contributor

Second attempt at #973.

@shcheklein shcheklein temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 07:33 Inactive
@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

Weird. This works for me locally (yarn dev) but crashes in the (built) review app (https://dvc-landing-server-redi-btalyj.herokuapp.com/)... Investigating ⏳

@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

@iAdramelk @shcheklein related: do you guys know why when you yarn build and yarn start this locally, it tries to enforce HTTPS on localhost:3000? Makes it impossible for me to debug the built app locally.

@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

Anyway, looking at https://dashboard.heroku.com/apps/dvc-landing-server-redi-btalyj/logs I see the review app error log is showing this a lot:

2020-02-20T07:43:44.228837+00:00 app[web.1]: TypeError: Cannot read property 'amp' of null
2020-02-20T07:43:44.228839+00:00 app[web.1]:     at Server.findPageComponents (/app/node_modules/next/dist/next-server/server/next-server.js:465:19)
...

which unfortunately is not a very informative stack trace... But per vercel/next.js#7303 (comment) this probably has to do with my changes around url.parse... Will try one of the fixes in that report ⏳

@iAdramelk
Copy link
Copy Markdown
Contributor

@jorgeorpinel

related: do you guys know why when you yarn build and yarn start this locally, it tries to enforce HTTPS on localhost:3000? Makes it impossible for me to debug the built app locally.

You can temporarily disable this redirect by commenting these lines: https://github.com/iterative/dvc.org/blob/master/src/utils/redirects.js#L37-L39

@shcheklein
Copy link
Copy Markdown
Contributor

@iAdramelk @fabiosantoscode @jorgeorpinel this is a bug . It should not be redirecting to https locally.

@fabiosantoscode
Copy link
Copy Markdown
Contributor

fabiosantoscode commented Feb 20, 2020

@jorgeorpinel NODE_ENV is set to production, making dev false, which makes the redirect stuff issue a redirect to HTTPS. I'll send a PR to avoid such a redirect on localhost.

UPDATE: See #1010

@shcheklein
Copy link
Copy Markdown
Contributor

@fabiosantoscode I would check if the redirects engine itself also matches on https only (thus preventing us from testing at least some redirects on localhost)

@fabiosantoscode
Copy link
Copy Markdown
Contributor

@shcheklein path redirects are relative, so they go to localhost. Hostname redirects (man.dvc.org, error.dvc.org) take you to the real site, where HTTPS works.

Copy link
Copy Markdown
Contributor

@fabiosantoscode fabiosantoscode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I found the reason for the crash you mentioned earlier.

Comment thread server.js Outdated
Comment thread src/utils/redirects.test.js Outdated
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 18:56 Inactive
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 19:08 Inactive
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 19:20 Inactive
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 19:27 Inactive
@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

Thanks Fabio, that was part of it.

Fixed this now in e51bc64 ! It's actually a kinda bug from Next... It expects that you always call url.parse sending true to its 2nd param (parseQueryString)... See vercel/next.js#7303 (comment)

@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

In any case... This review app works well now. https://dvc-landing-server-redi-btalyj.herokuapp.com/

Thanks everyone for all the feedback.

@jorgeorpinel jorgeorpinel marked this pull request as ready for review February 20, 2020 19:30
Comment thread server.js Outdated
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 23:17 Inactive
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 23:20 Inactive
and update scripts/exclude-links.txt accordingly
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-server-redi-btalyj February 20, 2020 23:27 Inactive
@shcheklein
Copy link
Copy Markdown
Contributor

👍 LGTM

@jorgeorpinel jorgeorpinel merged commit 82a9c4a into master Feb 21, 2020
@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

Deployed and double sanity checked on prod. All good! 🎉

@fabiosantoscode
Copy link
Copy Markdown
Contributor

@jorgeorpinel let me know if you had issues testing redirects locally. I tested them with:

curl -I --header 'host: man.dvc.org localhost:3000/something`

And checked the status code and location header for each redirect. This is also possible with HTTP GUIs like postman.

@jorgeorpinel
Copy link
Copy Markdown
Contributor Author

Seems to work properly after #1010. Thanks!

@jorgeorpinel jorgeorpinel deleted the server/redirects branch March 21, 2020 03:02
@jorgeorpinel jorgeorpinel added the A: website Area: website label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: website Area: website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants