search

Home  >  Q&A  >  body text

Angular + Cordova in virtual directory

I have an Angular application set up to run in a virtual directory. (https://{url}/{virtualDirectory})

I'm trying to wrap this application in a Cordova application that will point to a URL as the content source. (<content src="https://{url}/{virtualDirectory}"/>)

In my index.html file, I added the cordova.js script. (<script src="cordova.js"></script>)

My problem seems to be that Angular Router is getting in the way. When I debug the application I see the following console error:

caught Syntax error: unexpected token '<' at cordova.js:1:1

When I look at the source code I see that the Angular application's 404 page is rendered, so the Angular routing is trying to handle this path.

When we build and deploy in a Docker configuration we are setting the baseHref because we have to use a virtual folder:

ng build --base-href /{virtualDirectory}/ --configuration=$environment --output-path=dist

Rendered as <base href="/{virtualDirectory}/"> in the actual web page.

I tried googling this problem and couldn't find any suggestions on how to fix this (or at least none that worked). Can someone help point me in the right direction? TIA.

P粉551084295P粉551084295281 days ago790

reply all(1)I'll reply

  • P粉616383625

    P粉6163836252024-02-18 21:25:09

    I also encountered this problem when publishing on a virtual directory on the Apache server. What I followed is the following:

    1. Make sure your physical path folder and virtual directory folder should be the same. like:
    • Physical path: D:\some-path\project-name\audience
    • Virtual path: https://your-web-name/audience/d63b643da9b9cfc65e7d304b0aa33c98
    1. Run this commandng build --base-href ./ --deploy-url ./ (Note: This command will only work if you follow point 1 correctly)

    reply
    0
  • Cancelreply