Skip to content
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

Server-side rendering on content collection is pointed to the URL that is not reachable by the server. #1246

Open
awset opened this issue Sep 7, 2022 · 0 comments

Comments

@awset
Copy link
Collaborator

awset commented Sep 7, 2022

Describe the bug
This happened when I was working on the https://www.healthtranslations.vic.gov.au/ site and this was not working in the production environment only (lagoon) where the URL is not using the origin URL.

The baseURL that is used for this https://github.com/dpc-sdp/ripple/blob/develop/packages/ripple-nuxt-tide/lib/core/search.js#L51 is using the request header to determine the URL. This is becoming an issue on production env where the production URL healthtranslations.vic.gov.au is not reachable (it throws 404 exceptions), whereas the origin domain is reachable (in my case it is https://app.production.healthtranslations-vic-gov-au.sdp3.sdp.vic.gov.au/)

The code to set the baseURL is here, https://github.com/dpc-sdp/ripple/blob/develop/packages/ripple-nuxt-tide/lib/templates/plugin.js#L25

I did a patch for this specific patch to fix the issue, by adding this code to the https://github.com/dpc-sdp/ripple/blob/develop/packages/ripple-nuxt-tide/lib/templates/plugin.js

const host = (process.env.NODE_ENV === 'production' && process.env.CLIENT_HOST_URL) ? process.env.CLIENT_HOST_URL : req.headers.host

within this condition block

if (req) {
  const host = (process.env.NODE_ENV === 'production' && process.env.CLIENT_HOST_URL) ? process.env.CLIENT_HOST_URL : req.headers.host
  return req.protocol + '://' + host + apiRoot
  } else if (typeof window !== 'undefined') {
  return window.location.origin + apiRoot
}

and I added an environment variable to record the origin URL of production.

CLIENT_HOST_URL=app.production.healthtranslations-vic-gov-au.sdp3.sdp.vic.gov.au

To Reproduce
Steps to reproduce the behavior:

  1. Disable browser javascript
  2. Open the URL to the content collection e.g https://www.healthtranslations.vic.gov.au/advanced-search?items_per_page=50&field_node_resource_topic_name=Children%27s%20health

Or without disabling JS, you can view source the page

Expected behavior
Without JS enabled, there should hundreds of result in there.

Actual behavior
At the moment it returns a standard no result message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant