Search code examples
asp.net-coretwittercors

How to bring Twitter Tweet with Twitter Card to work?


I try to implement a Twitter Tweet button on my web page (asp.net core console app) with Twitter Card.
Goal: submit link to my web page, title, description and image (over the twitter meta tags) with the tweet (see image below).

All meta tags are filled correct on my web page (the target page).
If I paste the link to my web page in this tool: http://debug.iframely.com/?uri=<link_to_my_webpage>

Anything is showed correct (title, description and image): enter image description here

If I use the Twitter Card Validator: https://cards-dev.twitter.com/validator

I see an error message in card validator: "ERROR: Failed to fetch page due to: HttpConnectionTimeout"

If I load the browser debugger (all browsers), I see that some resources were blocked by CORS
No 'Access-Control-Allow-Origin'

Error Messages Google Chrome

Details:
Access to font at '**https://ton.twimg.com/tfw/fonts/rosetta-icons-Regular.woff**' from origin 'https://cards-dev.twitter.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

So.. both urls are twitter internal urls (not my site).
I assume, that the twitter tweet interface has the same problems and this is the reason that it does not work...
If I use the 3-th party tool (iframely, see link above), it works as expected, so it seems as the implementation of the metatags on my website is o.k..

Note: I already have implemented a FB share button (with the FB meta tags) on the same web page, that works without problems.

Thanks for any help (what can cause this problem and how to solve it).

Update to the solution:

  • It WAS the Port - see my comments to the accepted answer.
  • I still see the errors above in GC debugger, but this do not cause the problems.

Solution

  • Are you able to have your site at a URL that does not include an explicit port number? I think you may find that the Twitter Cards Validator does not like having a port number in the domain.