Adding Ads.txt file

import {ok, notFound, serverError} from 'wix-http-functions';
import wixData from 'wix-data';  //you can delete this line

let adstxt = `# Ads.txt
-------your text is missing and is needed!!! find it on google ads information about your missing file------ `;

export function get_Adstxt(request) {
let options = {
"headers": {
"Content-Type": "text/plain"
       },
"body": adstxt
   };
return ok(options)
}

Honestly I give up,. I need to redirect th page. Nothing works and I don’t care anymore. Absoltey ridiculous. Someone needs to make a video tutorial because I still don’t get how to do this

@ukiyotopublishing how did you do that?

Not working for me, could those who have had theirs work connect with me on twitter or something to explain this further for me? Monetary reward for successful explanation

oh, i should mention, my username on twitter is shizunofficial and the offer is still open

oh god this code also not working . please make sure wix support ads.txt or not?

I got it to work for me. inlovewithahouse.com/ads.txt.

looking at your code (based on what i did) you need to remove “import wixData from ‘wix-data’;”

another think i noticed for me was when creating the Backend name for the file it has to be exactly " http-functions.js "

@danteonheelies the Error message fortunately disappeared today. sent you a message on twitter. Check and let me know

i create Backend and paste this code
https://www.kollywoodwallpapers.com/ads.txt.
this page is not working
error message
please make video tutorial

it takes up to 24 hours until it disappears

Hi every one, i made a video to show you the steps to solve this issue.
find jason’s code here:


import {ok, notFound, serverError} from 'wix-http-functions';
// @see https://www.wix.com/corvid/forum/community-discussion/adding-ads-txt-file
let adstxt = `# Ads.txt
Add text here...`
export function get_Adstxt(request) {
	let options = {
		"headers": {
			"Content-Type": "text/plain"
		},
		"body": adstxt
	};
	return ok(options);
}

fine the google line here:
(don’t forget to replace the green part as shown in the video)

 google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0 

it takes up to 24 hours for google to fine the file in your site. be patiant :slight_smile:

goodluck!

super man …quick response its finally working . thank you so mush your are great. keep doing.

working good thank you man but adsense showing that

won’t worry its take time yesterday my google adsense also showing that but now its gone

That is an amazing video, so helpful. Many thanks. Just one question from my completely code-clueless self. I paste Jason’s code below the existing one, and I get a red dot on the very first line, quoting ‘parsing error identifier ‘ok’ has already been declared’. Does anybody know how to fix this? Please help.

[SOLVED] WOW I have no experience in coding but followed the steps carefully and it worked! THANK YOU. now will wait for approval and error message to go away.

TBN i guess that you have duplicated something wrong. could you paste your code here?

Thank you so much for replying, I would greatly appreciate your help if you have any feedback. Honestly, I’m clueless. This is what my code (with amended Publisher ID ) looks like:

import {ok, notFound, serverError} from ‘wix-http-functions’;
// @see https://www.wix.com/corvid/forum/community-discussion/adding-ads-txt-filehttps://www.wix.com/corvid/forum/community-discussion/adding-ads-txt-file
let adstxt = `# Ads.txt
google.com, pub-4710913340184559, DIRECT, f08c47fec0942fa0 ';
export function get_Adstxt(request) {
let options = {
“headers”: {
“Content-Type”: “text/plain”
},
“body”: adstxt
};
return ok(options);
}

looks perfect, is that all? or do you have anything above it? where did you place this code? did you create a new *.js beckend file as shown in the video?

I did, yes. When I open that new file, I paste this exact code on the end of the existing code. I guess it’s a default one, because I did not place the existing code. Maybe I should erase the existing code? I was afraid to mess around with a default code in case my website spontaneously combusts or something, I have no clue what consequences this sort of thing would have on the existing website. Of course I could be wrong and it could just not work for Adsense, leaving the website unaffected. I appreciate your help, immensely, thank you so much.