Cors filter problem, Origin:file:// error 403 forbidden

  • 4
  • Problem
  • Updated 4 years ago
Hy guys!

I've had encountered a problem with my android app.
The app works perfectly from browser, but with phonegap I can't send POST massages to my backend tomcat server.
The problem is that the header that the application send is "Origin:file://". The Tomcat CORS filter tries to validate the URI in Origin header and considers "file://" as an invalid URI and returns back 403. Is there any way to change manually my origin header, even an empty would satisfy my needs?
Photo of Attila Demeter

Attila Demeter

  • 1 Post
  • 0 Reply Likes

Posted 5 years ago

  • 4
Photo of Juan Leruga

Juan Leruga

  • 2 Posts
  • 0 Reply Likes
Hi, I have the same problem and I tried everything. I can't change the origin in the ajax call 'cause it's impossible. I put the "Allow-Access-Control-Origin" header with the value "*" and nothing changes.

Anybody dealt with these issue?

Thanks.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Juan,
- is this this your first hybrid app?
- are you using Phonegap Desktop App?
- are you using CLI, Build or SDK?

FWIW: Phonegap does NOT use CORS.

READ: #5 of Top Mistakes by Developers new to Cordova/Phonegap

Jesse
Photo of Juan Leruga

Juan Leruga

  • 2 Posts
  • 0 Reply Likes
@JesseMonroy650,
- is this this your first hybrid app?: No, it's not
- are you using Phonegap Desktop App? No.
- are you using CLI, Build or SDK? I'm using Build and CLI.

I solved it with that advice. I cut the CORS filter in the server and the "Allow-Access-Control-Origin" header in the ajax call. It worked!

Thank you, I think this is closed.
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Juan,
thanks for the reply.
Best of Luck
Jesse