Respond to Webhook for redirecting to a WordPress page

Describe the problem/error/question

I created an automation workflow to get 2 parameters from WordPress to n8n Webhook node, after comparing the course that the user attempted to take and the courses that the user had enrolled before in Moodle, to determine whether the user needs to attend the Pre-Course or not.

The final step after IF node, I want to redirect the user to a web page of Wordpress HTTP Responses2wpN – SEE Learning Taiwan if requiresPreCourse is true. Otherwise, a popup message will be shown to indicate the user to continue taking the course.

Although the “Respond to Webhook” node after IF node executed Successfully, nothing happened at the WordPress side. Chrome dev. shows it has been blocked by CORS policy, any suggestion to fix the CORS issue?

What is the error message (if any)?

Access to XMLHttpRequest at ‘https://lizen.app.n8n.cloud/webhook-test/check-course-pre-requisite’ from origin ‘https://see.architdz.tempurl.host’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Please share your workflow

Share the output returned by the last node

instance information

Debug info

core

  • n8nVersion: 1.64.3
  • platform: npm
  • nodeJsVersion: 20.18.0
  • database: sqlite
  • executionMode: regular
  • concurrency: 999
  • license: community
  • consumerId: 00000000-0000-0000-0000-000000000000

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 168 hours
  • maxCount: 2500 executions

Generated at: 2024-11-04T06:25:20.542Z

Information on your n8n setup

  • **n8n version: 1.64.3
  • **Database (default: SQLite): default
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Cloud
  • **Operating system: Windows

Added option “Allowed Origins (CORS)” in the Webhook node, it seems solved CORS issue, but still can not redirect to the WordPress page expected using HTTP Request node at the end of workflow.

Configuration of HTTP Request node:
URL: HTTP Responses2wpN – SEE Learning Taiwan
(**Tested above URL in the browser successfully redirected to the page expected.)
Method: GET
Query Parameter Key: requiresPreCourse Value: true
Options Follow Redirects enabled Max Redirects: 21

Output shows “Node executed successfully” but did not redirect to the WordPress page expected.

Any suggestion?
Thanks

Hello…is anybody there?

If this is the support we are going to get, I will be very hesitate…

Below is the reply from our hosting provider:

According to my test with cURL, it seems that the Nginx server is responding with a “301 Moved Permanently” status code and includes the “Location” header with the target URL for redirection. This indicates that the Nginx server is correctly configured to perform the redirect.

Since the cURL request is triggering the redirect as expected, the issue may lie within the n8n workflow or how the HTTP Request node is handling the response. Therefore, it may be helpful to further investigate the n8n workflow or consult with the n8n support for assistance in troubleshooting the redirection problem.

Hi @Sam_Mubie

Thanks for posting here and welcome to the community! :tada:

Could you share the rest of your workflow?

In order to respond with the redirect you will have to configure your webhook nodes to use the Respond to Webhook node and within that node set the redirect link.

Here’s a basic demo:

Hi there,

Our workflow

But our trial is over today. and it’s late here in Taiwan, I don’t know whether I will have the chance tomorrow to test your suggestion.

Will it be possible to extend our trial for some days?

Thanks

Hi @Sam_Mubie

I have extended your trial so you can test this out. Please let me know if that works for you?

Hi @ria

Still got

Problem in node ‘Webhook‘

Your trial has ended. Upgrade now to keep automating

Hi @ria

I can’t use my account since it is still blocked by trial ended when activating “Test Workflow”, but I do need to confirm the situation so I can show the workflow to my client tomorrow, and convince them to pay for your service.

So I had asked my college to copy the workflow using his account, but the problem is same as using HTTP Request…

Output shows successfully but did not redirect to the WordPress page expected.

Any idea what might be the cause?

Thanks

Hi @Sam_Mubie

We’re still working on getting your trial account back online so you can keep testing this in your own instance.

How are you calling this? Make sure you use the correct path (it will be a new one, since you’re using your colleagues’ account!) and also that the workflow is active.

Please note that the webhook node behaves different in test mode. So if you went to test this with the production URL from an external source (e.g. curl) it should redirect correctly. Can you confirm this?

Also, could you perhaps share your whole workflow here here so we can take a deeper look into what you’ve got at the moment?

Tip for sharing your workflow in the forum

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

Make sure that you’ve removed any sensitive information from your workflow and include dummy data or pinned data as much as you can!


Thanks! :pray:

Here is the workflow

I know there are Test URL and Production URL in Webhook node. We had run the workflow with Test URL successfully.
The problem is, it did not really redirect the user to the WordPress page expected.

Hi @Sam_Mubie

Thanks for sharing!
I made a little video for you and uploaded it in your gdrive link. Let me know if this helps to clarify things?

Also, your instance should be up and running with extended trial period :slight_smile:

Hi @ria

Please see the
Screen Recording
it went through the workflow successfully, but just did not really redirect to the target page.

An error occurred: Sorry you cannot post a link to that host.

When I want to add the link for target page( see.architdz.tempurl.host/http-responses2wpn/).

Hi @Sam_Mubie

Where did you get that error? I am starting to think this could be some issue with your hosting provider not accepting redirects :thinking:

So but just to understand the flow, the webhook is triggered when this is clicked, correct?

Anything in the Dev Tools that indicates how the site receives the redirect?

I’ve asked my hosting provider to add the Nginx rules for the custom redirect.

if you test this url in the browser, it will redirect you to the target url.

Is it the cause of conflict?

can not send the link…An error occurred: Sorry you cannot post a link to that host.

I have uploaded 2 logs from Dev Tools to gdrive. Trying to figure out what might related.

  • please ignore this message, the logs should not be relevant to the redirect.

the webhook is triggered when this is clicked, yes.
and Click “Take this Course” in this page will trigger the workflow successfully, but not redirect user to the target page.
You can test it using Username: test4see pw: Test4n8n1114