Markdown JS with two protocols

Version: 2.7.0.beta1
Install: discourse-docker

Hi everybody,

dont know how to better describe this but the markdown-it js bundle in our discourse installation is not correctly working. Somhow we get an additional protocol “https” added to the URL of the javascript (served via CDN and saved in our S3 bucket)

I added a screenshot.

Alll the other ressources are working fine

Its just this and due to this, we dont get a preview function :frowning:

Thanks for your time and looking forward :slight_smile:

Screenshot of the other working ressources:

Can you share your app.yml file here ?

yes of course.

## Managed by Ansible. Do not change on server
## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  #- "templates/postgres.template.yml"
  #- "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: '16GB'

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 8

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: 'community-dev.stackit.cloud'

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'xxx'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: '1.2.3.4'
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: 'xx@xx.de'
  DISCOURSE_SMTP_PASSWORD: 'xxx'
  DISCOURSE_SMTP_ENABLE_START_TLS: true
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  #LETSENCRYPT_ACCOUNT_EMAIL: info@ediri.de

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com
  #DISCOURSE_CDN_URL: community-cdn.change.me

  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

  DISCOURSE_DB_POOL: 16
  DISCOURSE_DB_USERNAME: 'discourse'
  DISCOURSE_DB_PASSWORD: 'yyy'
  DISCOURSE_DB_HOST: 1.2.3.4
  DISCOURSE_DB_NAME: 'discourse'
  DISCOURSE_DB_PORT: 5432

  DISCOURSE_REDIS_HOST: 'y.de'
  DISCOURSE_REDIS_PASSWORD: 'xxx'
  DISCOURSE_REDIS_PORT: 49456

  DISCOURSE_MESSAGE_BUS_REDIS_ENABLED: true
  DISCOURSE_MESSAGE_BUS_REDIS_HOST: 'y.de'
  DISCOURSE_MESSAGE_BUS_REDIS_PORT: 49456
  DISCOURSE_MESSAGE_BUS_REDIS_PASSWORD: 'xxx'

  DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: whatever
  DISCOURSE_S3_ENDPOINT: https://assets.xxx
  DISCOURSE_S3_ACCESS_KEY_ID: 'discourse-dev'
  DISCOURSE_S3_SECRET_ACCESS_KEY: 'xxx'
  DISCOURSE_S3_CDN_URL: https://discourse-dev.assets.xxx
  DISCOURSE_S3_BUCKET: 'discourse-dev'
  DISCOURSE_S3_BACKUP_BUCKET: 'discourse-dev/backups'
  DISCOURSE_BACKUP_LOCATION: s3
  DISCOURSE_S3_INSTALL_CORS_RULE: false

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
  host: /var/discourse/shared/standalone
  guest: /shared
  - volume:
  host: /var/discourse/shared/standalone/log/var-log
  guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
- exec:
    cd: $home/plugins
    cmd:
      - git clone https://github.com/discourse/docker_manager.git
      - git clone https://github.com/discourse/discourse-cakeday.git
      - git clone https://github.com/discourse/discourse-oauth2-basic.git
      #- git clone https://github.com/discourse/discourse-bbcode.git

  after_assets_precompile:
- exec:
    cd: $home
    cmd:
      - sudo -E -u discourse bundle exec rake s3:upload_assets

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  - exec: rails r "SiteSetting.notification_email='xxx@xxx.de'"
  - exec: echo "End of custom commands"

Are you running behind a reverse proxy? Have you set force_https on the settings?

yes, force_https is set. And no, no reverse proxy apart from the inbaked nginx.

What is weird is the fact, that the other JS are working fine, with the CDN url. Its just the markdown-it…

I dont know where to look in the code, not that i know ruby. :slight_smile: :grinning:

1 Like

is there any additional informations you would need to point me to a solution? Shoudl i maybe check the code?

hi, anyone has an idea on how to solve this?

1 Like

Something weird about your setup.

You have a S3 CDN setup, but it is on the same URL as the bucket?

data-s3-cdn="https://discourse-dev.assets.schwarz" 
data-s3-base-url="//discourse-dev.assets.schwarz"

Comparing with Meta:

data-s3-cdn="https://d11a6trkgmumsb.cloudfront.net" 
data-s3-base-url="//assets-meta-cdck-prod-meta.s3.dualstack.us-west-1.amazonaws.com"

The code that load dynamic scripts will try to replace the S3_BASE_URL for S3_CDN:

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse-common/addon/lib/get-url.js#L35-L37

1 Like

ja both URLS are the same, as we use Minio for an s3-compatible object storage.

@Falco, you where right. Seperating both urls helped to fix the issue :slight_smile:

Thanks for the help :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.