Ejabberd: cross domain http image upload

Created on 1 Aug 2017  路  3Comments  路  Source: processone/ejabberd

What version of ejabberd are you using?

17.07

What operating system (version) are you using?

Windows 7

How did you install ejabberd (source, package, distribution)?

ejabberd-17.07-windows-installer.exe

What did not work as expected? Are there error messages in the log? What
was the unexpected behavior? What was the expected result?

when i try to upload file from cross domain am getting this error

XMLHttpRequest cannot load http://192.168.2.235:5280/upload
  /ec7fcf7902c2576c7e6bca6aaa4a80cde0a32395
  /ypJBd6DG7Uvo8NjutmUGHocpHC513WUI2Y0yfeMM/cc.png.
 Response to preflight request doesn't pass access control check:
 No 'Access-Control-Allow-Origin' header is present on the requested resource.
 Origin 'http://localhost:50644' is therefore not allowed access.

and my config yml is:

mod_http_upload:
    docroot: "@HOST@/upload"
    put_url: "http://@HOST@:5280/upload"
    get_url: "http://@HOST@:5280/upload"
    thumbnail: false
    custom_headers:
      "Access-Control-Allow-Origin": "*"
      "Access-Control-Allow-Methods": "OPTIONS, HEAD, GET, PUT"
      "Access-Control-Allow-Headers": "Content-Type"

port: 5280
    ip: "::"
    module: ejabberd_http
    request_handlers:
      "/websocket": ejabberd_http_ws
      "/api": mod_http_api
      "/upload": mod_http_upload
    ##  "/pub/archive": mod_http_fileserver
    web_admin: true
    http_bind: true
    register: true
    captcha: false

thanks...

Most helpful comment

So this seems to be a result of mismatch between Host: header in http request, and domain used by ejabberd, if you use same domain for both this is working for me.

All 3 comments

So this seems to be a result of mismatch between Host: header in http request, and domain used by ejabberd, if you use same domain for both this is working for me.

ya that is the issue thanks..

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings