These are chat archives for opal/opal

15th
Oct 2016
Bernhard Weichel
@bwl21
Oct 15 2016 15:43

I ran in an issue with Opal server again ...

    HTTP.get("public/locale/conf-help_#{language}.json").then do |response|
      $conf_helptext = Native(response.body)
    end.fail do |response|
      alert "could not loaad confhelp #{response}"
    end.always do |response|

works with Opal::Server but not with another websevrer. It seems that with Opal server HTTP.get returns the parsed JSON as object, but with others (eg. Apache on my production machine) it returns the parsed JSON as string. Are there some settings to prevent this?

meh.
@meh
Oct 15 2016 15:46
bwl21, make sure the Content-Type is correct
Bernhard Weichel
@bwl21
Oct 15 2016 20:41
@meh to be honest, I do not know how to set the content type neither in Opal:server nor in Apache :-( but when I observe the communication in the browser, Opal::Server says: Content-Type:application/json while apache says Content-Type:text/plain. This explains the difference.
meh.
@meh
Oct 15 2016 20:41
bwl21, yes, that's the problem
you need to set up Apache to send the right Content-Type
or the browser won't know what to do with it
Bernhard Weichel
@bwl21
Oct 15 2016 20:42
Is there a way to tell Opal::server to deliver JSON-Files as text?
meh.
@meh
Oct 15 2016 20:42
why would you do that
Bernhard Weichel
@bwl21
Oct 15 2016 20:43
I am not sure if I can customize the apache on a shared web hoster.
Is it done in .htaccess?
meh.
@meh
Oct 15 2016 20:43
yes
Bernhard Weichel
@bwl21
Oct 15 2016 20:43
Ok, so I will ask my hoster how to do this.
at the moment, I made my app such that it investigates the type of the payload
thanks.