Results 1 to 3 of 3

Thread: "sencha app watch" with CORS and session cookie.

  1. #1

    Default "sencha app watch" with CORS and session cookie.

    When developing software it is very important to keep a short code/testing cycle. Typically, the advantage of interpreted languages in web-technology is the possibility of reloading a page to test it. Therefore I found it great to use "sencha app watch". I do not want to spend 30 seconds to build the app after each change.

    This however ran into problems when my app started to use ajax data from a backend server. It became necessary to keep that server on a different port. So essentially I had two urls: //the rest API for my data //the app served by "sencha app watch"

    However, despite them being on the same domain, chrome treats these URLs as being on different domains because of the different port number. For example, chrome creates separate cookies for these URLs. This means that I have to use CORS technique.

    For my ajax backend to work, I also needed the browser to send a session cookie with some session id.

    After a lot of research I found that it was possible to do something like this. For example this description:

    However, in order to follow their recipe, It is necessary to change the response headers for the served app to something like:

    Header set Access-Control-Allow-Origin ""
    Header set Access-Control-Allow-Credentials true

    But how to do that when I just use "sencha app watch"? Any .htaccess file I place in the sencha app directory is ignored.

    The Response Headers I get from sencha app watch are just:

    HTTP/1.1 200 OKAccept-Ranges: bytesContent-Type: text/htmlContent-Length: 1982Last-Modified: Thu, 17 May 2018 06:54:06 GMTServer: Jetty(8.1.22.v20160922)

    Is there any way to change things here?

  2. #2
    Sencha Premium User
    Join Date
    Feb 2009
    Kragujevac, Serbia


    Here is a solution I'm using
    - create a simple proxy servlet that will forward calls to backend adress
    - in root folder of sencha app create WEB-INF folder and lib folder inside it
    - copy servlet to lib folder
    - add web.xml in WEB-INF and register servlet in it
    - start sencha app watch with following command "sencha app watch -j"

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2011


    Not an answer to your question, but I think you can achieve your goal in a different way. I find using Sencha Cmd's built-in reverse proxy server a convenient and easy solution for this. I explained it here:

Similar Threads

  1. cors direct api request haven't send cookie header
    By waahai in forum Ext JS 6.x Q&A
    Replies: 2
    Last Post: 20 Jan 2016, 6:24 PM
  2. Sencha CMD Allow Cors
    By deadManN in forum Sencha Cmd
    Replies: 2
    Last Post: 8 Dec 2015, 10:00 PM
  3. Ext.ux.state.WindowNameProvider a (session) cookie alternative
    By devtig in forum Ext:User Extensions and Plugins
    Replies: 1
    Last Post: 14 Nov 2012, 12:19 PM
  4. Session Cookie not being sent with Form Submission
    By twktue in forum Sencha Ext JS Q&A
    Replies: 2
    Last Post: 13 Jun 2011, 7:31 AM
  5. Replies: 0
    Last Post: 28 Mar 2011, 4:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts