Posted in Uncategorized

Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header

Today’s error is the following:
localhost:8100/#/app/login:1 XMLHttpRequest cannot load http://mysite.local/api/login. 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:8100’ is therefore not allowed access.

I was working on ionic & everything was working fine. Then I tried to use a login API. Suddenly from nowhere, it threw up the error . I guessed, it’s from the server side. But, again it works fine from the apk . Hmm, strange!
Then I installed a chrome-app Allow-control-allow-origin . And then, they he coded happily thereafter. Happy ending for the day!

Advertisements
Posted in Uncategorized

Android set up device for development (?????? no permissions)

Today I was trying to debugging on Device from ubuntu 14.04 & I was badly stuck.
Being new to Android, I was in the setup & debugging maze.
Now I was trying to debug from my smart phone.

        1. First thing I did was installing adb-tools. This lets you connect mobile devices to your machine for debugging
          sudo apt-get install android-tools-adb
        2. sudo apt-get install android-tools-adb
        3. Next Create a file named /tmp/android.rules with the following contents (hex vendor numbers were taken from the vendor list page)
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0e79", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="413c", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="091e", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="18d1", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="24e3", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="2116", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0482", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0409", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0955", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="2257", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="10a9", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="1d4d", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0471", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="04da", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="05c6", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="1f53", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="04dd", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="0930", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="19d2", MODE="0666"
          SUBSYSTEM=="usb", ATTRS{idVendor}=="1bbb", MODE="0666"
          
        4. Run the following commands:
          sudo cp /tmp/android.rules /etc/udev/rules.d/51-android.rules
          sudo chmod 644   /etc/udev/rules.d/51-android.rules
          sudo chown root. /etc/udev/rules.d/51-android.rules
          sudo service udev restart
          sudo killall adb

           

        5. Disconnect the USB cable between the phone and the computer.  Reconnect the phone. Run
          adb devices

          to confirm that now it has permission to access the phone.